简介
Error : Cannot execute request on any known server
翻译过来就是:无法在任何已知服务器上执行请求。这个错误提示信息,相信小伙伴们在配置
SpringCloud
的时候,经常会遇到。虽然这个错误提示看似简单,但是能够引发它的原因就太多了,多不胜数,任何一点配置发生错误,都可能导致发生这个错误。
以下解决该错误的一种原因,是由于
版本不一致
导致的错误。
还原错误发生情况
导致错误:虽然
Provider
可以正常对Consumer
提供服务,可以正常注册Eureka
,但是会一直报错误。
错误大致信息
c.n.d.s.t.d.RedirectingEurekaHttpClient : `Request execution error`
`javax.ws.rs.WebApplicationException: null`com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-DEMO/192.168.1.101:provider-demo:8000 - `was unable to refresh its cache! status = Cannot execute request on any known server`
com.netflix.discovery.shared.transport.TransportException: `Cannot execute request on any known server`
父项目pom文件配置信息
<!-- 父项目引入的Spring Boot版本号 -->
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.3.RELEASE</version><relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- 父项目引入的Spring Cloud版本号,Finchley.RELEASE对应的是Spring Boot 2.X版本 -->
<properties><spring.cloud.version>Finchley.RELEASE</spring.cloud.version>
</properties>
<dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring.cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement>
子项目pom文件配置信息
错误分析,当写了
<version>RELEASE</version>
,导入的是与Spring Boot相对应地版本号,默认导入的是<version>Finchley.RELEASE</version>
中管理的版本号
<!-- 默认引入eureka-clent,版本号为:2.0.0.RELEASE -->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- 当我们写了`<version>RELEASE</version>`后,引入eureka-client,版本号为:2.1.3.RELEASE -->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId><version>RELEASE</version>
</dependency>
默认导入与RELEASE
对比
Finchley.RELEASE
中管理的版本号
完整错误信息
2019-10-24 09:23:54.766 INFO 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-10-24 09:23:54.766 INFO 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-10-24 09:23:54.767 INFO 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-10-24 09:23:54.767 INFO 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-10-24 09:23:54.767 INFO 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-10-24 09:23:54.767 INFO 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2019-10-24 09:23:54.767 INFO 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-10-24 09:23:54.772 ERROR 59687 --- [freshExecutor-0] c.n.d.provider.DiscoveryJerseyProvider : Unexpected error occurred during de-serialization of discovery data, done connection cleanup
2019-10-24 09:23:54.772 ERROR 59687 --- [freshExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution errorjavax.ws.rs.WebApplicationException: nullat com.netflix.discovery.provider.DiscoveryJerseyProvider.readFrom(DiscoveryJerseyProvider.java:107) ~[eureka-client-1.9.2.jar:1.9.2]at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:634) ~[jersey-client-1.19.1.jar:1.19.1]at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:586) ~[jersey-client-1.19.1.jar:1.19.1]at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplicationsInternal(AbstractJerseyEurekaHttpClient.java:198) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplications(AbstractJerseyEurekaHttpClient.java:165) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:120) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1051) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:965) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1471) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1438) [eureka-client-1.9.2.jar:1.9.2]at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_212]at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_212]at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]2019-10-24 09:23:54.772 WARN 59687 --- [freshExecutor-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: null
2019-10-24 09:23:54.772 ERROR 59687 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_PROVIDER-DEMO/192.168.1.101:provider-demo:8000 - was unable to refresh its cache! status = Cannot execute request on any known servercom.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known serverat com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1051) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:965) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1471) [eureka-client-1.9.2.jar:1.9.2]at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1438) [eureka-client-1.9.2.jar:1.9.2]at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_212]at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_212]at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]