openFegin Read timed out executing POST

157 阅读1分钟

feign.RetryableException: Read timed out executing POST http://......

问题描述

SpringCloud微服务之间远程调用报错超时。

java
复制代码
feign.RetryableException: Read timed out executing POST http://......

原因及解决方案

这是一个http请求报错超时,因为feign的调用分为两层:Ribbon的调用和Hystrix的调用,所以我们在配置文件中添加超时配置即可。高版本的Hystrix默认是关闭的,可以不设置。

java
复制代码
#hystrix的超时时间
hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 30000
#ribbon的超时时间
ribbon:
  ReadTimeout: 30000
  ConnectTimeout: 30000