本文介绍了同一应用程序中的配置服务器和尤里卡服务器:尝试连接到 localhost:8761的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 spring-boot 应用程序,我用来在开发和测试环境中设置一个 spring cloud 配置服务器 和一个 eureka 服务器.奇怪的是,应用程序总是尝试连接到 localhost:8761,即使我将 eureka.client.registerWithEureka 设置为 false.

I have a spring-boot application which I use to setup a spring cloud config server and a eureka server in development and testing environments.Strangely the application always tries to connect to localhost:8761, even though I have eureka.client.registerWithEureka set to false.

如何停用此功能?

错误:

ERROR 3144 --- [et_localhost-12] c.n.e.cluster.ReplicationTaskProcessor   : Network level connection to peer localhost; retrying after delay

com.sun.jersey.api.client.ClientHandlerException: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out
    at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
    at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.4.10.jar:1.4.10]
    at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.4.10.jar:1.4.10]
    at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1]
    at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116) ~[eureka-core-1.4.10.jar:1.4.10]
    at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:71) ~[eureka-core-1.4.10.jar:1.4.10]
    at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187) [eureka-core-1.4.10.jar:1.4.10]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_92]
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out

我唯一的类是这样的:

@EnableEurekaServer
@EnableConfigServer
@SpringBootApplication
public class MyApplication {
  public static void main(String[] args) {
    SpringApplication.run(MyApplication.class, args);
  }
}

application.yml:

server:
  port: 8888

eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
  server:
    waitTimeInMsWhenSyncEmpty: 0
    renewal-percent-threshold: 0.49

security:
  basic:
    enabled: true
  user:
    password: mypassword


spring:
  jmx:
    default-domain: ${spring.application.name}
  cloud:
    config:
      server:
        git:
          uri: https://example.com/myrepo.git
          username: username
          password: password
          clone-on-start: true
          search-paths: '{application},{application}/{profile}'

endpoints:
  jmx:
    domain: ${spring.application.name}
    unique-names: true

bootstrap.yml 中,我只设置了应用程序名称.

In the bootstrap.yml I have only the application name set.

版本:

spring-cloud-netflix-eureka: 1.1.6,spring-cloud-config-server: 1.1.3

spring-cloud-netflix-eureka: 1.1.6,spring-cloud-config-server: 1.1.3

推荐答案

你可以尝试像下面那样改变你的配置吗

Could you try to change your configuration like below

eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
    service-url:
      defaultZone: http://localhost:8888/eureka

您指定 server.port: 8888.所以你的尤里卡在 8888 端口上运行.但是您没有为尤里卡指定任何服务网址.所以我认为你的尤里卡服务器正试图复制到 localhost:8761 因为它是默认的,你没有为尤里卡指定 service-url .

You specify server.port: 8888. So your eureka is running on 8888 port. But you didn't specify any service-url for eureka. So I think that your eureka server is trying to replicate to localhost:8761 because it's default and you didn't specify service-url for eureka.

这篇关于同一应用程序中的配置服务器和尤里卡服务器:尝试连接到 localhost:8761的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 12:05