openfeign调用服务提供者报错com.netflix.hystrix.exception.HystrixRuntimeException,未配置hystrix默认1秒超时。
解决:
给服务调用者和提供者同时配置下feign、hystrix、ribbon的超时时间
- feign:
- httpclient:
- enabled: true
- client:
- config:
- default:
- #建立连接所用的时间,适用于网络状况正常的情况下,两端连接所需要的时间
- ConnectTimeOut: 10000
- #指建立连接后从服务端读取到可用资源所用的时间
- ReadTimeOut: 10000
- #调用admin微服务接口配置
- member-admin:
- ConnectTimeOut: 10000
- ReadTimeOut: 5000
- hystrix:
- command:
- #全局默认配置
- default:
- #线程隔离相关
- execution:
- timeout:
- #是否给方法执行设置超时时间,默认为true。一般我们不要改。
- enabled: true
- isolation:
- #配置请求隔离的方式,这里是默认的线程池方式。还有一种信号量的方式semaphore。
- strategy: THREAD
- thread:
- #方式执行的超时时间,默认为1000毫秒,在实际场景中需要根据情况设置
- timeoutInMilliseconds: 10000
- # 实例配置
- HystrixCommandKey:
- execution:
- timeout:
- enabled: true
- isolation:
- strategy: THREAD
- thread:
- timeoutInMilliseconds: 10000
- # ribbon 的超时时间
- ribbon:
- ReadTimeout: 3000
- ConnectTimeout: 3000