昨天在部署环境的时候整个集群均为实例报错,但是zuul的日志报错
com.netflix.zuul.exception.ZuulException:Forwarding error
Caused by: java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out
Caused by: java.net.SocketTimeoutException: Read timed out
很明显,根据报错信息,应该是zuul的调用等待时间超时
在zuul中加入如下配置的简化版
##timeout confighystrix: ?command: ???default: ?????execution: ???????timeout: ?????????enabled: true ???????isolation: ?????????thread: ???????????timeoutInMilliseconds: 60000ribbon: ?ReadTimeout: 60000 ?ConnectTimeout: 60000 ?MaxAutoRetries: 0 ?MaxAutoRetriesNextServer: 1 ?eureka: ???enabled: falsezuul: ?max: ???host: ?????connections: 500 ?host: ???socket-timeout-millis: 60000 ???connect-timeout-millis: 60000
该配置中也包括了集群中单个实例报错,控制zuul调用其它实例的方法(尝试重新调用集群中服务器的数量,和超时后对本实例的再次重试次数)
同时在fegin的调用端也要用对应的ribbon和hystrix的配置,用来覆盖其默然配置的三秒超时时间,因为每次服务器重新启动之后,初次访问实例初始话的过程中比较耗时,所以在初次访问的时候超时的概率很大,
所以需要加上次配置抵消容器初始话后首次调用的超时现象。
对于首次调用超时的情况,还可以设置对应的feign.hystrix.enabled=false,默认去关闭hystrix的功能也是可以的,但是不推荐,尤其是生产环境
com.netflix.zuul.exception.ZuulException:Forwarding error
原文地址:https://www.cnblogs.com/dauber/p/9424505.html