generator-jhipster: Setting up Ribbon's Connection timeout in microservice environment
I’m trying to configure the gateway’s zuul connection timeout and have added the ConnectTimeout parameter to the gateway’s application.yml The ConnectTimeout timeout seems to be ignored. We need a way to specify this parameter.
ribbon:
eureka:
enabled: true
ConnectTimeout: 30000
ReadTimeout: 30000
One of my microservices is slow to return a response (and that’s ok) so I’m seeing lots of error in the gateway log:
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: hpwebservices timed-out and no fallback available.
at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:806)
at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:790)
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:99)
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70)
at com.netflix.hystrix.AbstractCommand$DeprecatedOnFallbackHookApplication$1.onError(AbstractCommand.java:1521)
at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1411)
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:314)
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:306)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (9 by maintainers)
Here is my config, maybe we should consider adding to generated yml files.
Just add below snippet at application.yml where located at gateway-ms that works perfect
We had this issue too. One of our microservices was taking ~3 seconds to complete, so 90% of the time we would get the timeout error even though the service completed successfully.
Out of the box, Ribbon’s
ReadTimeout, andConnectTimeoutare both1000. These values are found in RibbonClientConfiguration.javaThe Ribbon timeout is calculated in AbstractRibbonCommand.java:
ribbonTimeout = (ribbonReadTimeout + ribbonConnectTimeout) * (maxAutoRetries + 1) * (maxAutoRetriesNextServer + 1);maxAutoRetriesandmaxAutoRetriesNextServervalues are found in DefaultClientConfigImpl.javaWe updated our gateway’s
application.ymland added:This keeps the
ribbonTimeoutcalculation at10000which matches the value ofhystrix.command.default.execution.isolation.thread.timeoutInMilliseconds.(4000 + 1000) * (0 + 1) * (1 + 1)
This avoids receiving errors like this:
gateway-app_1 | 2018-11-14 15:54:36.072 WARN 1 --- [ XNIO-2 task-16] o.s.c.n.z.f.r.s.AbstractRibbonCommand : The Hystrix timeout of 10000ms for the command microservice is set lower than the combination of the Ribbon read and connect timeout, 12000ms.Finally, the Ribbon property names are case sensitive, ie
ReadTimeout, notread-timeout, orreadTimeout.@PierreBesson I can do that. Where would the best place be to put this?
Here is what I read to make it work:
https://github.com/spring-cloud/spring-cloud-netflix/issues/321