Java Netflix Eureka,负载平衡器没有可用于客户端的服务器

Java Netflix Eureka,负载平衡器没有可用于客户端的服务器,java,spring-boot,microservices,netflix-eureka,netflix-zuul,Java,Spring Boot,Microservices,Netflix Eureka,Netflix Zuul,我正在尝试用netflix库创建SpringBootMicroservices项目。获取请求(http://localhost:5000/api/player)导致错误的原因: com.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(Ribbon

我正在尝试用netflix库创建SpringBootMicroservices项目。获取请求(http://localhost:5000/api/player)导致错误的原因:

com.netflix.zuul.exception.ZuulException: Forwarding error
    at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:198) ~[spring-cloud-netflix-zuul-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:173) ~[spring-cloud-netflix-zuul-2.2.0.RELEASE.jar:2.2.0.RELEASE]
    at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:119) ~[spring-cloud-netflix-zuul-2.2.0.RELEASE.jar:2.2.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]

Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: player-service
    at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483) ~[ribbon-loadbalancer-2.3.0.jar:2.3.0]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184) ~[ribbon-loadbalancer-2.3.0.jar:2.3.0]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180) ~[ribbon-loadbalancer-2.3.0.jar:2.3.0]
    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]
发现服务器:

@SpringBootApplication
@EnableEurekaServer
public class EurekaDiscoveryApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaDiscoveryApplication.class, args);
    }

}
网关服务器:

我还尝试使用@enableurekaclient

@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
public class GatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }

}
将功能区特性设置为true无效

spring.application.name=gateway-service
server.port=5000
eureka.client.serviceUrl.defaultZone=http://localhost:4000/eureka/

eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true

zuul.prefix=/api

zuul.routes.player-service=/player/**
zuul.routes.player-service.service-id=player-service

ribbon.eureka.enabled=false
spring.cloud.loadbalancer.ribbon.enabled=false
客户端服务器:

@SpringBootApplication
@EnableEurekaClient
public class EurekaClientPlayerApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaClientPlayerApplication.class, args);
    }

}
/本地主机:4000

/eureka/apps:

<applications>
<versions__delta>1</versions__delta>
<apps__hashcode>UP_2_</apps__hashcode>
<application>
<name>PLAYER-SERVICE</name>
<instance>
<instanceId>host.docker.internal:player-service:4002</instanceId>
<hostName>host.docker.internal</hostName>
<app>PLAYER-SERVICE</app>
<ipAddr>192.168.1.6</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">4002</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1618253227798</registrationTimestamp>
<lastRenewalTimestamp>1618253407804</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1618253227798</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>4002</management.port>
<jmx.port>11640</jmx.port>
</metadata>
<homePageUrl>http://host.docker.internal:4002/</homePageUrl>
<statusPageUrl>http://host.docker.internal:4002/actuator/info</statusPageUrl>
<healthCheckUrl>http://host.docker.internal:4002/actuator/health</healthCheckUrl>
<vipAddress>player-service</vipAddress>
<secureVipAddress>player-service</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1618253227798</lastUpdatedTimestamp>
<lastDirtyTimestamp>1618253227773</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
<application>
<name>GATEWAY-SERVICE</name>
<instance>
<instanceId>host.docker.internal:gateway-service:5000</instanceId>
<hostName>host.docker.internal</hostName>
<app>GATEWAY-SERVICE</app>
<ipAddr>192.168.1.6</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">5000</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1618253217688</registrationTimestamp>
<lastRenewalTimestamp>1618253397688</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1618253217688</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>5000</management.port>
<jmx.port>11625</jmx.port>
</metadata>
<homePageUrl>http://host.docker.internal:5000/</homePageUrl>
<statusPageUrl>http://host.docker.internal:5000/actuator/info</statusPageUrl>
<healthCheckUrl>http://host.docker.internal:5000/actuator/health</healthCheckUrl>
<vipAddress>gateway-service</vipAddress>
<secureVipAddress>gateway-service</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1618253217688</lastUpdatedTimestamp>
<lastDirtyTimestamp>1618253217654</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
</applications>

1.
向上2_
球员发球
主机。docker。内部:播放器服务:4002
host.docker.internal
球员发球
192.168.1.6
向上的
不为人知
4002
443
1.
我的
30
90
1618253227798
1618253407804
0
1618253227798
4002
11640
http://host.docker.internal:4002/
http://host.docker.internal:4002/actuator/info
http://host.docker.internal:4002/actuator/health
球员发球
球员发球
假的
1618253227798
1618253227773
补充
网关服务
主机。docker。内部:网关服务:5000
host.docker.internal
网关服务
192.168.1.6
向上的
不为人知
5000
443
1.
我的
30
90
1618253217688
1618253397688
0
1618253217688
5000
11625
http://host.docker.internal:5000/
http://host.docker.internal:5000/actuator/info
http://host.docker.internal:5000/actuator/health
网关服务
网关服务
假的
1618253217688
1618253217654
补充
我知道这是一个常见的问题,我尝试了类似问题的多种解决方案,但都不起作用。你能帮忙吗

@RestController
public class PlayerController {

    @GetMapping
    public String get() {
        return "player";
    }

}
spring.application.name=player-service
server.port=4002
eureka.client.serviceUrl.defaultZone=http://localhost:4000/eureka/

eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
<applications>
<versions__delta>1</versions__delta>
<apps__hashcode>UP_2_</apps__hashcode>
<application>
<name>PLAYER-SERVICE</name>
<instance>
<instanceId>host.docker.internal:player-service:4002</instanceId>
<hostName>host.docker.internal</hostName>
<app>PLAYER-SERVICE</app>
<ipAddr>192.168.1.6</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">4002</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1618253227798</registrationTimestamp>
<lastRenewalTimestamp>1618253407804</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1618253227798</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>4002</management.port>
<jmx.port>11640</jmx.port>
</metadata>
<homePageUrl>http://host.docker.internal:4002/</homePageUrl>
<statusPageUrl>http://host.docker.internal:4002/actuator/info</statusPageUrl>
<healthCheckUrl>http://host.docker.internal:4002/actuator/health</healthCheckUrl>
<vipAddress>player-service</vipAddress>
<secureVipAddress>player-service</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1618253227798</lastUpdatedTimestamp>
<lastDirtyTimestamp>1618253227773</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
<application>
<name>GATEWAY-SERVICE</name>
<instance>
<instanceId>host.docker.internal:gateway-service:5000</instanceId>
<hostName>host.docker.internal</hostName>
<app>GATEWAY-SERVICE</app>
<ipAddr>192.168.1.6</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">5000</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1618253217688</registrationTimestamp>
<lastRenewalTimestamp>1618253397688</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1618253217688</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>5000</management.port>
<jmx.port>11625</jmx.port>
</metadata>
<homePageUrl>http://host.docker.internal:5000/</homePageUrl>
<statusPageUrl>http://host.docker.internal:5000/actuator/info</statusPageUrl>
<healthCheckUrl>http://host.docker.internal:5000/actuator/health</healthCheckUrl>
<vipAddress>gateway-service</vipAddress>
<secureVipAddress>gateway-service</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1618253217688</lastUpdatedTimestamp>
<lastDirtyTimestamp>1618253217654</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
</applications>