8

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?

chaitanya dalvi
  • 1,539
  • 2
  • 17
  • 25

2 Answers2

26

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

feign.client.config.default.connectTimeout: 160000000
feign.client.config.default.readTimeout: 160000000
chaitanya dalvi
  • 1,539
  • 2
  • 17
  • 25
  • 1
    what if one wants to throw a custom exception when the time out occurs. How does one do tgat ? – jackfr0st Sep 27 '19 at 07:54
  • surround your get/post/delete call by try/catch and wrap the `SocketTimeoutException` in an exception of your choosing. – Binoy Dalal Nov 03 '20 at 21:28
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