我尝试将Eureka服务器连接到Eureka客户端,但没有成功。全部放在一个容器里。Docker/Container Network设置为Host。
我尝试在我的桌面上托管这两者:我尝试在我的Raspberry pi: Works上同时托管这两个作品
但是当我在我的Raspberry Pi上托管服务器时,我无法从我的桌面连接服务。我试了很多次都没成功。
旁注:我可以访问Eureka Dashboard,并且我有另一个Container正在运行,并且在我的桌面上成功连接到SQL数据库,我想应该不会有网络问题。
客户端
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服务器
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: true192.168.0.20是我的桌面192.168.0.69是我的树莓派
这有可能吗?我尝试了很多不同的设置。就像我说的,都是在本地或在树莓树上托管的作品。
提前感谢
错误消息:
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发布于 2021-08-15 15:11:34
我能够通过向defaultZone添加${eureka_url:}来解决这个问题。现在效果很好。
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: truehttps://stackoverflow.com/questions/68787073
复制相似问题