java.net.SocketTimeoutException Read timed out

异常信息:

2018-08-14 00:13:50.976 [http-nio-8080-exec-5] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] 182 - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.RetryableException: Read timed out executing POST http://ace-miguan/jxl/task] with root cause
java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
        at java.net.SocketInputStream.read(SocketInputStream.java:171)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)

原因:
通过日志发现 当控制层访问微服务的响应时间超过5秒
通过查阅资料发现是很多博主都说是hystrix断路器的配置问题
通过查找源码发现了如下的配置文件
源码定义如下
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds:断路器的超时时间需要大于ribbon的超时时间,不然不会触发重试。
hello-service.ribbon.ConnectTimeout:请求连接的超时时间
hello-service.ribbon.ReadTimeout:请求处理的超时时间
hello-service.ribbon.OkToRetryOnAllOperations:对所有操作请求都进行重试
hello-service.ribbon.MaxAutoRetriesNextServer:切换实例的重试次数
hello-service.ribbon.MaxAutoRetries:对当前实例的重试次数

解决:
项目添加以下配置
ribbon:
ReadTimeout: 600000
ConnectTimeout: 600000
MaxAutoRetries: 0
MaxAutoRetriesNextServer: 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值