spring-cloud-zuul timeout configuration does not work

我怕爱的太早我们不能终老 提交于 2019-12-11 05:25:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!