记录一下,springcloud,在使用feign调用微服务的时候,出现异常java.util.concurrent.TimeoutException: nul,
这个时候,一般是配置熔断器的问题,
熔断hystrix默认超时的时间为1秒,如果超过这个时间,就会抛出以上异常,这个时候,需要设置禁用超时时间,或者加大超时时间。操作如下:
- 在application.yml中设置熔断的检测时间:(默认时间为1秒,我这里设置为5秒)
#配置熔断的时间监听 hystrix: command: default: execution: timeout: isolation: thread: timeoutInMilliseconds: 5000 - 在application.yml中设置关闭熔断的检测功能:
#关闭hystrix时间检测功能 hystrix: command: default: execution: timeout: enabled: false - 在application.yml中,直接关闭(禁用)Feign的hystrix。
#关闭feign的hystrix feign: hystrix: enabled: false
然后重启测试,就OK了。
本文详细介绍了在SpringCloud环境下使用Feign调用微服务时遇到超时异常的解决方法,包括调整Hystrix熔断器的超时时间、禁用Hystrix熔断功能以及关闭Feign的Hystrix配置。





