When the API service is restarted initially. If I call the API service directly, it works but if I call it through the feign client, I'll see the hystrix fallback message for a few seconds. And If API service is not running when I call it through the zuul, I'll see the following error message:
com.netflix.zuul.exception.ZuulException: Hystrix Readed time out
How can I solve this problem?
By default, Zuul throws exception when upstream service is not available instead of throwing 503/404. You need to extend ErrorFilter
and handle the exception with custom behavior.
That's why when the API service is not running you get ZuulException
.
This behavior has been discussed in detail in Zuul swallows 503 exceptions from upstream microservices GitHub thread.
Some of the approaches to deal with this exception is explain in this SO thread: Customizing Zuul Exception.