问题
according to spring cloud zuul 8.1.3 zuul timeout, the following configuration should make zuul timeout after 20 seconds, however, it times out at 10 seconds.
server:
port: 8769
spring:
application:
name: service-zuul
zuul:
host:
connect-timeout-millis: 20000
socket-timeout-millis: 60000
zuul:
routes:
tp:
path: /**
url: http://localhost:9998
ribbon:eureka:enabled: false
From console output one can see that the interval between filter and timeout exception is only 10 seconds. which means the zuul.host.connect-timeout-millis
does not work.
回答1:
I finally found a solution:
I used properties before and this is the first time to try yml, it seems that an item must be aggregated into one prefix:
zuul:
host:
connect-timeout-millis: 20000
socket-timeout-millis: 60000
routes:
tp:
path: /**
url: http://localhost:9998
In this way the backend server could have at most 60 seconds to respond. Besides, I also found that the sequence in configuration matters.
回答2:
Try to define the below properties instead if you are using Zuul withe Eureka.
ribbon:
ReadTimeout: 60000
ConnectTimeout: 20000
If you are using Zuul with Eureka, Zuul will use RibbonRoutingFilter
for routing instead of SimpleHostRoutingFilter
. In this case, HTTP requests are handled by Ribbon.
来源:https://stackoverflow.com/questions/49525707/spring-cloud-zuul-timeout-configuration-does-not-work