解决:The Hystrix timeout of xxx ms for the command xxxx is set lower than the combination of the Ribbon
项目具体报错如下:
2019-09-19 17:46:48.283 [http-nio-7777-exec-3] WARN o.s.c.n.z.f.route.support.AbstractRibbonCommand - The Hystrix timeout of 5000ms for the command SERVICE is set lower than the combination of the Ribbon read and connect timeout, 400000ms.
分析:
hystrix超时设置:
# 默认超时时间
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds = 6000
# 具体应用的超时时间
hystrix.command.xxx.execution.isolation.thread.timeoutInMilliseconds = 6000
Ribbon
# 总时间ribbonTimeout = (ribbonReadTimeout + ribbonConnectTimeout) * (maxAutoRetries + 1) * (maxAutoRetriesNextServer + 1);
# 笔者这里的具体值为:(5000+5000)*(1+1)*(1+1)=40000;
而Hystrix 时间为:5000,具体办法也好办,在配置文件中修改超时为:
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 40000
或者修改ribbon配置:
AUSERVICE: #这是ribion要请求的serviceID
ribbon:
ReadTimeout: 2000
ConnectTimeout: 2000
MaxAutoRetries: 0
MaxAutoRetriesNextServer: 0
即:(2000+2000)(0+1)(0+1)=4000<5000也可。
ribbon全局设置,超时时间:(2000+1000)(0+1)(1+1)=6000:
ribbon.ReadTimeout = 2000 # 访问超时,单位毫秒,默认1000
ribbon.ConnectTimeout = 1000 # 连接超时,单位毫秒,默认1000
ribbon.MaxAutoRetries = 0 # 最大重试次数,默认0
ribbon.MaxAutoRetriesNextServer = 1 # 最大重试服务个数,默认1
本文由 创作,采用 知识共享署名4.0 国际许可协议进行许可。本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为: 2021/04/05 03:24