首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将Eureka客户端注册到Eureka服务器

将Eureka客户端注册到Eureka服务器
EN

Stack Overflow用户
提问于 2021-08-14 21:14:34
回答 1查看 795关注 0票数 1

我尝试将Eureka服务器连接到Eureka客户端,但没有成功。全部放在一个容器里。Docker/Container Network设置为Host。

我尝试在我的桌面上托管这两者:我尝试在我的Raspberry pi: Works上同时托管这两个作品

但是当我在我的Raspberry Pi上托管服务器时,我无法从我的桌面连接服务。我试了很多次都没成功。

旁注:我可以访问Eureka Dashboard,并且我有另一个Container正在运行,并且在我的桌面上成功连接到SQL数据库,我想应该不会有网络问题。

客户端

代码语言:javascript
运行
复制
server:
  port: 9001


spring:
  application.name: USER-SERVICE
  cloud:
    inetutils:
      preferred-networks:
        - 192.168

eureka:
  instance:
    prefer-ip-address: true
    hostname: 192.168.0.20
  client:
    fetch-registry: true
    register-with-eureka: true
    service-url:
      defeaultZone: http://192.168.0.69:8761/eureka

服务器

代码语言:javascript
运行
复制
server:
  port: 8761


eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://192.168.0.69:8761/eureka
  instance:
    hostname: 192.168.0.69
    prefer-ip-address: true

192.168.0.20是我的桌面192.168.0.69是我的树莓派

这有可能吗?我尝试了很多不同的设置。就像我说的,都是在本地或在树莓树上托管的作品。

提前感谢

错误消息:

代码语言:javascript
运行
复制
2021-08-15 00:40:24.177  INFO 16044 --- [           main] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-15 15:11:34

我能够通过向defaultZone添加${eureka_url:}来解决这个问题。现在效果很好。

代码语言:javascript
运行
复制
eureka:
  client:
    fetch-registry: true
    register-with-eureka: true
    service-url:
      defaultZone: ${eureka_url:http://192.168.0.69:8761/eureka}
  instance:
    hostname: 192.168.0.69
    prefer-ip-address: true
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68787073

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档