SpringCloud中 A服务通过远程调用B服务接口,如果A服务没有配置feign超时时间,那么A服务调用B服务能够成功,但是获取不到B服务的响应,然后就会直接报错:

feign.RetryableException: Read timed out executing POST http://zboot-mms/mms/email/sendHtml
	at feign.FeignException.errorExecuting(FeignException.java:249)
	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:120)
	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:80)
	。。。。。。
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)
	。。。。。。

这是A服务的报错,但是实际上B服务的接口已经调用成功了

解决:
给A服务配置Feign超时时间

feign:
  client:
    config:
      default:
        #不设置connectTimeout会导致readTimeout设置不生效
        connectTimeout: 3000
        readTimeout: 6000