版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaogc_a/article/details/82504614
今天,在调式服务间调用的时候遇到以下问题 :
Caused by: java.net.SocketTimeoutException: Read timed out
百度查了一下,默认的请求时间为1秒,超过这个时间便超时异常
解决方法有多种:
以下是网上所谓的三种方法: 说三种任意一种都能解决问题
1、把时间设长
这里设置5秒
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 5000
2、把超时发生异常属性关闭
hystrix:
command:
default:
execution:
timeout:
enabled: false
3、禁用feign的hystrix
feign:
hystrix:
enabled: false
但是!但是并没有解决我的问题:
我是这样解决的:
#打开feign-hystrix
feign:
hystrix:
enabled: true
client:
config:
ebook-interfaces: #服务提供者名字
connectTimeout: 5000
readTimeout: 5000
完美解决