Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring cloud Zuul转发错误_Spring Cloud_Netflix Zuul_Spring Cloud Netflix_Netflix_Netflix Feign - Fatal编程技术网

Spring cloud Zuul转发错误

Spring cloud Zuul转发错误,spring-cloud,netflix-zuul,spring-cloud-netflix,netflix,netflix-feign,Spring Cloud,Netflix Zuul,Spring Cloud Netflix,Netflix,Netflix Feign,我在使用Zuul和Ribbon时遇到问题。我还使用Eureka进行微服务注册 我有一个功能区服务(端口9000),它使用RESTAPI与用户服务通信 用户服务有2个实例(在端口8081和8091上) 在ribbon服务上,我使用hystrix和Faign client实现了客户端负载平衡 我使用Zuul路由使用ribbon服务API,然后该API触发用户服务API 当我启动我的微服务生态系统并尝试使用ribbon服务API(zuulservice:8761/ribbon service/)时

我在使用Zuul和Ribbon时遇到问题。我还使用Eureka进行微服务注册

  • 我有一个功能区服务(端口9000),它使用RESTAPI与用户服务通信
  • 用户服务有2个实例(在端口8081和8091上)
  • 在ribbon服务上,我使用hystrix和Faign client实现了客户端负载平衡
  • 我使用Zuul路由使用ribbon服务API,然后该API触发用户服务API
当我启动我的微服务生态系统并尝试使用ribbon服务API(zuulservice:8761/ribbon service/)时,我收到以下错误:

com.netflix.zuul.exception.zuuleexception:转发错误 在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] 在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] 在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] 在com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:117)~[zuul-core-1.3.1.jar:1.3.1] 在com.netflix.zuul.FilterProcessor.processzupulfert(FilterProcessor.java:193)~[zuul-core-1.3.1.jar:1.3.1] 在com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:157)~[zuul-core-1.3.1.jar:1.3.1] 在com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:118)~[zuul-core-1.3.1.jar:1.3.1] 在com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:96)~[zuul-core-1.3.1.jar:1.3.1] 在com.netflix.zuul.http.ZuulServlet.route(ZuulServlet.java:116)~[zuul-core-1.3.1.jar:1.3.1] 在com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:81)~[zuul-core-1.3.1.jar:1.3.1] 位于org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:165)[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE] 在org.springframework.cloud.netflix.zuul.web.ZuulController.handleRequest(ZuulController.java:44)[spring-cloud-netflix-zuul-2.0.0.RELEASE.jar:2.0.0.RELEASE] 位于org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:52)[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE] 位于org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)[spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]。。。。。。。。。。。。。。。。 原因:com.netflix.client.ClientException:负载平衡器没有可用于客户端功能区服务的服务器 在com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483)~[ribbon-loadbalancer-2.2.5.jar:2.2.5] 在com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184)~[ribbon-loadbalancer-2.2.5.jar:2.2.5] 在com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180)~[ribbon-loadbalancer-2.2.5.jar:2.2.5] 在rx.Observable.unsafeSubscribe(Observable.java:10327)~[rxjava-1.3.8.jar:1.3.8] 在rx.internal.operators.onSubscribeContmap.call(onSubscribeContmap.java:94)~[rxjava-1.3.8.jar:1.3.8] 在rx.internal.operators.onSubscribeContmap.call(onSubscribeContmap.java:42)~[rxjava-1.3.8.jar:1.3.8] 在rx.Observable.unsafeSubscribe(Observable.java:10327)~[rxjava-1.3.8.jar:1.3.8]

此错误会保留一段时间,之后我会得到以下输出:

2018-07-16 12:55:43.260信息19233---[erListUpdater-0]c.netflix.config.ChainedDynamicProperty:翻转属性:ribbon-service.ribbon.ActiveConnectionsLimit使用下一个属性:niws.loadbalancer.availabilityFilteringRule.ActiveConnectionsLimit=2147483647

在输出之后,一切又恢复正常

当我点击eurekaservice:8765/eureka/apps时,我已经注册了ribbon服务和所有用户服务实例

这是我的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
> #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
这是我的zuul服务bootstrap.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
> #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
我正在使用Spring2.0.1和SpringCloudFinchley.RELEASE

有人能解释一下发生了什么事吗


谢谢大家!

DiscoveryClient的工作方式是,它从
Eureka
(服务发现)获取每个定义的时间段(称为
hearbeat
)的新更改列表。在注册应用程序的新更改从服务发现传播到Zuul实例之前,它肯定会有错误


<>你在日志中看到的输出只是确认它已经收到了这个信息。

你可以考虑为ZUUL配置添加条路径配置。< /P>
在每个路由配置中添加stripPrefix=false

听起来好像Zuul还不知道
功能区服务
。在启动Zuul之前,您是否正在启动功能区服务?如果在Zuul之后启动,Zuul从Eureka获取更新信息需要一段时间。它总是在Zuul服务之前启动。如果
功能区服务在Zuul之前启动,并且在Zuul启动之前注册,它应该包括在Zuul启动时从Eureka服务器获取的服务列表中在尤里卡注册。我不知道我们还能做什么。你能提供一个重现问题的样本吗?@RyanBaxter谢谢你的努力。我按正确的顺序启动它们,但有时会出现这种错误。直到zuul服务提示this:INFO 19233---[erListUpdater-0]c.netflix.config.ChainedDynamicProperty:Flipping属性:ribbon-service.ribbon.ActiveConnectionsLimit到u,错误才会消失