com.netflix.discovery.shared.transport.TransportException:无法在任何已知服务器上执行请求

2022-09-01 00:14:13

我对微服务非常陌生,并尝试从链接运行代码:https://dzone.com/articles/advanced-microservices-security-with-spring-and-oa。当我简单地运行代码时,我看到以下错误来了。

问题是什么?

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
    at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) ~[eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1030) [eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:944) [eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1468) [eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1435) [eureka-client-1.4.12.jar:1.4.12]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_144]
    at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_144]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_144]

2017-09-09 18:53:11.909 ERROR 16268 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error

我没有在系统上安装任何特殊的东西。请让我知道我需要安装什么?

enter image description here


答案 1

我发现我必须将这两个应用程序添加到appllication.properties中,它可以工作。只有一个是不够的。

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

答案 2

发生这种情况是因为它正在尝试连接到任何已知服务器,因此要停止该错误,已知服务器是端口8761上的eureka服务器,这是其默认端口,您必须更新应用程序。properties,如下所示

server.port=8761

若要避免 eureka 注册自身,请将它添加到应用程序.properties 中。

eureka.client.register-with-eureka=false

确保 EurekaServer 已启用,例如使用 Spring boot,在主类上编写以下内容。

@EnableEurekaServer

请原谅我使用.properties文件提供解决方案,但这就是我使用的内容,但.yml配置不应该有太大的不同。


推荐