feign.RetryableException: 读取执行 GET 超时

feign.RetryableException: Read timed out executing GET

我的项目中有以下架构

我的 UI 服务(端口 8080)正在假装调用网关服务(端口 8085)。
我来自 UI 服务的 Get 调用是“http://localhost:8080/invoice-list?startDate=2018-08-05&endDate=2018-10-05
来自网关服务的类似调用“http://localhost:8085/invoice-download-service/invoice-list?startDate=2018-08-05&endDate=2018-10-05

当我从 UI 服务发出此 GET 调用时,我在

分钟内收到以下错误消息
 is feign.RetryableException: Read timed out executing GET http://localhost:8085/invoice-download-service/invoice-list?startDate=2018-08-05&endDate=2018-10-05] with root cause

java.net.SocketTimeoutException: Read timed out

但是当我从网关服务器直接调用微服务时,我没有收到错误。

Application.properties 网关服务文件

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=160000000

ribbon.OkToRetryOnAllOperations=true
ribbon.ReadTimeout=5000000
ribbon.ConnectTimeout=5000000
ribbon.MaxAutoRetries=3
ribbon.MaxAutoRetriesNextServer=3


zuul.host.socket-timeout-millis= 5000000
zuul.host.connect-timeout-millis= 5000000

我在这里设置了 readtimeout 和 connecttimeout 属性 大约 8 到 10 分钟,因此我没有收到错误。

Application.properties UI 服务的文件

spring.application.name=external-ui-service

server.port=8080

这里 UI 服务我没有超时 属性。我在这里尝试了上述属性但没有用。 显然这个 UI 服务没有使用 ribbon、zuul 等。这只是一个对网关的 Feign 调用。

那么我应该怎么做才能增加 UI 服务的超时时间?

在 UI 服务的 application.propeties 文件中添加了以下属性。

feign.client.config.default.connectTimeout: 160000000
feign.client.config.default.readTimeout: 160000000

这个问题也可能是由 Spring Cloud Gateway 的默认 laodbalancer 实现引起的,如果你使用 Eureka Server 并且 运行 你的微服务在 windows 上取消了。服务在本地主机上 运行ning,但 Eureka 告诉网关的负载均衡器将请求路由到 host.docker.internal。 下面的链接提供了几个解决方案:

https://localcoder.org/spring-boot-cloud-eurka-windows-10-eurkea-returns-host-docker-internal-for-clien

https://dimitr.im/fix-eureka-localhost