客户端在调用feign接口时,项目接口莫名其妙出现feign.RetryableException: Incomplete output stream executing POST XXXX,错误截图如下:
查询半天常见的解决办法有两个:
1)、因为原来Feign采用JDK原生HttpURLConnection向下游服务发起http请求,使用Apache HttpClient替换掉原生的HttpURLConnection。
①、pom.xml新增依赖
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
②、yml文件新增配置:
feign:
httpclient:
enabled: true
2)、Feign的调用分为两层:Ribbon的调用和Hystrix的调用,增加连接超时时长:
#ribbon的超时时间
ribbon:
ReadTimeout: 600000
ConnectTimeout: 600000
#hystrix的超时时间
hystrix:
command:
default:
execution:
timeout:
enabled: true
isolation:
thread:
timeoutInMilliseconds: 300000
上面两个方法试了之后还是没有解决问题,后面才发现同事加了拦截器处理feign请求头参数:
在百度的时候确认遇到有相同的帖子,且跟踪源码的时候发现请求头Content-Length有两个值,请求头中删掉Content-Length参数,让feign接口自己处理这个参数,问题就此解决。