在使用Spring Cloud的时候遇见了 这个异常:
feign.RetryableException: Read timed out executing POST xxxxxx
at feign.FeignException.errorExecuting(FeignException.java:65)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:105)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:77)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:102)
at com.sun.proxy.$Proxy113.generateUserContract(Unknown Source)
.....
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at feign.Client$Default.convertResponse(Client.java:150)
at feign.Client$Default.execute(Client.java:72)
spring boot :2.0.6.RELEASE
spring cloud :Finchley.SR2
组件中使用了 Eureka 、Feign ,因为Feign中引用了Ribbon,所以就没有显示引用jar.
再往上找到了各种遇见这个问题的解决方案,但是在这个版本号之内已经没有了:
ribbon.connect-timeout和ribbon.read-timeout 这两个变量的定义,所以在看了官方文档之后:
feign.client.config.default.connect-timeout=20000 feign.client.config.default.read-timeout=20000
这两个参数就可以解决timeout的问题。