ZuulException (SendErrorFilter) at first call ZuulException (SendErrorFilter) at first call docker docker

ZuulException (SendErrorFilter) at first call


There should be 3 things we need to keep on the top of our head for the request which are gone through the Zuul

1) According to this Document - https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/1.4.3.RELEASE/single/spring-cloud-netflix.html#_zuul_eager_application_context_loading

Zuul internally uses Ribbon for calling the remote url’s and Ribbon clients are by default lazily loaded up by Spring Cloud on first call. This behavior can be changed for Zuul using the following configuration and will result in the child Ribbon related Application contexts being eagerly loaded up at application startup time.

application.yaml

zuul:   ribbon:      eager-load:         enabled: true

application.properties

zuul.ribbon.eager-load.enabled= true

2) According to this Document - http://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_service_discovery_configuration

Service Discovery Configuration ---If Zuul is using service discovery there are two timeouts you need to be concerned with, the Hystrix timeout (since all routes are wrapped in Hystrix commands by default) and the Ribbon timeout. The Hystrix timeout needs to take into account the Ribbon read and connect timeout PLUS the total number of retries that will happen for that service. By default Spring Cloud Zuul will do its best to calculate the Hystrix timeout for you UNLESS you specify the Hystrix timeout explicitly.

The Hystrix timeout is calculated using the following formula:

(ribbon.ConnectTimeout + ribbon.ReadTimeout) * (ribbon.MaxAutoRetries + 1) * (ribbon.MaxAutoRetriesNextServer + 1)

As an example, if you set the following properties in your application properties

application.yaml

ribbon:   ReadTimeout:100   ConnectTimeout:500   MaxAutoRetries:1   MaxAutoRetriesNextServer:1

application.properties

ribbon.ReadTimeout= 100ribbon.ConnectTimeout= 500ribbon.MaxAutoRetries= 1ribbon.MaxAutoRetriesNextServer= 1

Then the Hystrix timeout (for all routes in this case) will be set to 2400ms.


In my zuul application config I have added the following properties. And it's working for my 1st call with out any error.

application.yaml

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 11000ribbon:   ConnectTimeout: 10000   ReadTimeout: 10000

application.properties

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds= 11000ribbon.ConnectTimeout= 10000ribbon.ReadTimeout: 10000

3) This is the most easiest way. Disable the hystrix execution time out.

According to this Document -https://github.com/Netflix/Hystrix/wiki/Configuration#executiontimeoutenabled

Following property will disable the hystrix execution time out on Zuul

application.properties

hystrix.command.default.execution.timeout.enabled=false

If we keep remember these 3 scenarios then we can easily get the solution of ZuulException (SendErrorFilter).


According to this documentation:

Zuul internally uses Ribbon for calling the remote URLs. By default, Ribbon clients are lazily loaded by Spring Cloud on first call. This behavior can be changed for Zuul by using the following configuration, which results eager loading of the child Ribbon related Application contexts at application startup time.

The following example shows how to enable eager loading:

# application.ymlzuul:  ribbon:    eager-load:      enabled: true

Or

# application.propertiesribbon.eager-load.enabled = true

You might need to check the following related issues:


Change the URL from localhost to the service name mentioned in the discovery client.