2
votes

I am facing issues using Zuul and Ribbon. I am using also Eureka for microservice registry.

  • I have ribbon-service(port 9000) communicating with the user-service using the REST API
  • user-service has 2 instances (on port 8081 and 8091)
  • on ribbon-service I have implemented client-side load balancing using hystrix and feign client
  • I consume ribbon-service API using Zuul route, and this API then triggers user-service API

When I start my microservice ecosystem and try to consume ribbon-service API(zuulservice:8761/ribbon-service/) I get the following error:

com.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:189) ~[spring-cloud-netflix-zuul-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:164) ~[spring-cloud-netflix-zuul-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:112) ~[spring-cloud-netflix-zuul-2.0.0.RELEASE.jar:2.0.0.RELEASE] at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:117) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:193) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:157) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:118) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:96) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.http.ZuulServlet.route(ZuulServlet.java:116) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:81) ~[zuul-core-1.3.1.jar:1.3.1] at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:165) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.cloud.netflix.zuul.web.ZuulController.handleRequest(ZuulController.java:44) [spring-cloud-netflix-zuul-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:52) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]................ Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: ribbon-service at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483) ~[ribbon-loadbalancer-2.2.5.jar:2.2.5] at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184) ~[ribbon-loadbalancer-2.2.5.jar:2.2.5] at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180) ~[ribbon-loadbalancer-2.2.5.jar:2.2.5] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8]

This error remains for some time, and after that time I get the following output:

2018-07-16 12:55:43.260 INFO 19233 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: ribbon-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647

After that output everthing works great again.

When I hit eurekaservice:8765/eureka/apps I have registered both ribbon-service and all the user-service instances.

This is my zuul service application.properties:

> #Service port
server.port=8765

#Service port
spring.application.name=zuul-service

# Discovery Server Access
 eureka.client.service-url.defaultZone:http://localhost:8761/eureka/
 eureka.instance.lease-renewal-interval-in-seconds=3

 #User service configuration
 zuul.routes.user-service.path:/user-service/**
 zuul.routes.user-service.serviceId:user-service

 #Product service configuration
 zuul.routes.product-service.path:/product-service/**
 zuul.routes.product-service.serviceId:product-service

 #Product service configuration
 zuul.routes.shoppingcart-service.path:/shoppingcart-service/**
 zuul.routes.shoppingcart-service.serviceId:shoppingcart-service

 #Product service configuration
 zuul.routes.payment-service.path:/payment-service/**
 zuul.routes.payment-service.serviceId:payment-service

  #Product service configuration
 zuul.routes.ribbon-service.path:/ribbon-service/**
 zuul.routes.ribbon-service.serviceId:ribbon-service

This is my zuul-service bootstrap.properties:

> #Application name
spring.application.name=zuul-service

#hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 12600
ribbon.ConnectTimeout: 6000   
ribbon.ReadTimeout: 60000
robbon.eureka.enabled: true

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

I am using spring 2.0.1 and spring cloud Finchley.RELEASE.

Can somebody explain what is going on?

Thank you!

2
Sounds like Zuul does not yet know about the ribbon-service. Are you starting ribbon-service before starting Zuul? If you are starting it after Zuul it will take some time before Zuul gets the updated information from Eureka.Ryan Baxter
It is always started before the zuul service.branko terzic
If the ribbon-service is started before Zuul and it registers itself before Zuul starts it should be included in the list of services fetched from the Eureka server when Zuul registers itself with Eureka. I am not sure what else we can do. Can you provide a sample that reproduces the problem?Ryan Baxter
@RyanBaxter thank you for you effort. I start them in correct order, but sometimes this error occurs. Error remains until zuul-service prompt this: INFO 19233 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: ribbon-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647, cab you explain what is this property for?branko terzic

2 Answers

0
votes

The way DiscoveryClient works is that it fetches new list of changes from Eureka (Service discovery) for every defined time period called hearbeat. Until new changes with respect to registered applications propagates from service discovery to your Zuul instance it is bound to have errors.

The output you see in the logs is just the confirmation that it has received this information.

0
votes

You may consider add strip path config for your zuul configuration.

add stripPrefix=false in every route config