我在Eureka注册了以下服务
edge-server
是一个像这样配置的Zuul代理:
zuul:
routes:
contacts-service:
path: /contacts/**
stripPrefix: true
serviceId: contacts-service
ribbon:
eureka:
enabled: true
eureka:
client:
serviceUrl:
defaultZone: http://eureka:admin@127.0.0.1:8761/eureka/
instance:
preferIpAddress: true
---
spring:
profiles: docker
eureka:
client:
serviceUrl:
defaultZone: http://eureka:admin@discovery:8761/eureka/
在制作中,一切都是固定的(不知道这个问题是否重要)。
当我尝试通过zuul调用联系人服务时,我收到此异常
{
"timestamp": 1477595822755,
"status": 500,
"error": "Internal Server Error",
"exception": "com.netflix.zuul.exception.ZuulException",
"message": "NUMBEROF_RETRIES_NEXTSERVER_EXCEEDED"
}
并且日志显示
10/27/2016 9:21:10 PM[2m2016-10-27 19:21:10.921[0;39m [33m WARN[0;39m [35m1[0;39m [2m---[0;39m [2m[nio-8080-exec-3][0;39m [36mo.s.c.n.z.filters.post.SendErrorFilter [0;39m [2m:[0;39m Error during filtering
10/27/2016 9:21:10 PM
10/27/2016 9:21:10 PMcom.netflix.zuul.exception.ZuulException: Forwarding error
10/27/2016 9:21:10 PM at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:164) ~[spring-cloud-netflix-core-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
10/27/2016 9:21:10 PM at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
10/27/2016 9:21:10 PM at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
10/27/2016 9:21:10 PM at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_92-internal]
10/27/2016 9:21:10 PM at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_92-internal]
10/27/2016 9:21:10 PM at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
10/27/2016 9:21:10 PM at java.lang.Thread.run(Thread.java:745) [na:1.8.0_92-internal]
10/27/2016 9:21:10 PMCaused by: com.netflix.client.ClientException: Number of retries on next server exceeded max 1 retries, while making a call for: a0821971c1d0:contacts-service:72887579
10/27/2016 9:21:10 PM at com.netflix.loadbalancer.reactive.LoadBalancerCommand$4.call(LoadBalancerCommand.java:350) ~[ribbon-loadbalancer-2.2.0.jar!/:2.2.0]
10/27/2016 9:21:10 PM at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:133) ~[spring-cloud-netflix-core-1.2.0.RELEASE.jar!/:1.2.0.RELEASE]
10/27/2016 9:21:10 PM ... 68 common frames omitted
10/27/2016 9:21:10 PMCaused by: java.net.UnknownHostException: a0821971c1d0
10/27/2016 9:21:10 PM at java.net.InetAddress.getAllByName0(InetAddress.java:1280) ~[na:1.8.0_92-internal]
10/27/2016 9:21:10 PM at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[na:1.8.0_92-internal]
10/27/2016 9:21:10 PM at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[na:1.8.0_92-internal]
10/27/2016 9:21:10 PM at com.netflix.loadbalancer.reactive.LoadBalancerCommand$3$1.call(LoadBalancerCommand.java:287) ~[ribbon-loadbalancer-2.2.0.jar!/:2.2.0]
10/27/2016 9:21:10 PM at rx.internal.util.ScalarSynchronousObservable$3.call(ScalarSynchronousObservable.java:231) ~[rxjava-1.1.10.jar!/:1.1.10]
10/27/2016 9:21:10 PM ... 161 common frames omitted
10/27/2016 9:21:10 PM
如您所见,它在日志中显示java.net.UnknownHostException: a0821971c1d0
。好像Zuul无法解决instace地址。如果需要,我可以发布更多信息。