feign.RetryableException: Read timed out executing GET
Asked Answered
S

3

12

I have below architecture in my projectenter image description here

My UI Service(Port 8080) making Feign call to Gateway Service(Port 8085).
My Get call from UI service is " http://localhost:8080/invoice-list?startDate=2018-08-05&endDate=2018-10-05 "
Similar call from Gateway Service "http://localhost:8085/invoice-download-service/invoice-list?startDate=2018-08-05&endDate=2018-10-05"

When i make this GET call from UI service i get below error within minute

 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

But when i make direct call from Gateway Server to microservice, i dont get error.

Application.properties file of Gateway service

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

Here i have set readtimeout and connecttimeout property around 8 to 10 min, hence i am not getting error.

Application.properties file of UI service

spring.application.name=external-ui-service

server.port=8080

Here in UI service i dont have timeout property. I tried above properties here but not working. Obviously this UI service is not using ribbon,zuul etc. This is just an making Feign call to gateway.

So what should i do to increase timeout in UI service?

Sour answered 5/10, 2018 at 11:7 Comment(0)
S
31

Added below properties in UI Service's application.propeties file.

feign.client.config.default.connectTimeout: 160000000
feign.client.config.default.readTimeout: 160000000
Sour answered 9/10, 2018 at 7:13 Comment(4)
what if one wants to throw a custom exception when the time out occurs. How does one do tgat ?Rapp
surround your get/post/delete call by try/catch and wrap the SocketTimeoutException in an exception of your choosing.Enate
for me those properties take no effectHollyhock
So, I was using Spring openfeign starter which expects slightly different config paths: spring.cloud.openfeign.client.config.default.connectTimeout and spring.cloud.openfeign.client.config.rankings-api.readTimeoutHollyhock
H
1

In case you are using the spring-cloud-starter-openfeign dependency, you should use a slightly different properties:

spring.cloud.openfeign.client.config.default.connectTimeout=123000
spring.cloud.openfeign.client.config.default.readTimeout=123000

Also, instead of using a "default" client name which refers to all clients, you can specify some exact client name in configs, e.g.: spring.cloud.openfeign.client.config.orders-client.readTimeout

The name orders-client is coming from the client's declaration:

@FeignClient(
  name = "orders-client",
...
)

Documentation link: https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#spring-cloud-feign-overriding-defaults

Hollyhock answered 7/2, 2024 at 15:39 Comment(0)
S
0

This issue might also be caused by default laodbalancer implementation of Spring Cloud Gateway in case you make use of Eureka Server and run your microservices undockerized on windows. Services are running on localhost, but Eureka says to the loadbalancer of the gateway to route the request to host.docker.internal. The links down below give a couple of solutions:

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

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

Surplice answered 22/4, 2022 at 10:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.