报错日志:
java.net.SocketTimeoutException: Read timed out
一。没有开启hystrix熔断配置,即配置文件没有配置如下信息
#打开feign-hystrix
feign:
hystrix:
enabled: true
处理方式,设置ribbon的请求超时的时间即可:
#请求处理的超时时间
ribbon:
ReadTimeout: 4000
#请求连接的超时时间
ConnectTimeout: 3000
原理:高版本的springcloud-openfeign请求分为两层,先ribbon控制,后hystrix控制,hystrix默认处于关闭状态
二。开启hystrix,配置hystrix的超时时间即可
#打开feign-hystrix
feign:
hystrix:
enabled: true
#hystrix 配置
hystrix:
command:
default:
execution:
timeout:
#如果enabled设置为false,则请求超时交给ribbon控制
enabled: true
isolation:
thread:
timeoutInMilliseconds: 5000
三。如何判断feign请求时超时还是被降级处理
1.请求超