我使用Netflix eureka构建了2个微服务。他们使用假装客户进行沟通。在我的本地环境中假装客户端工作没有任何问题。但是在Predix(云代工厂)环境中,他们无法沟通。假设客户端总是给出连接超时错误。由于发现feign客户端尝试使用实例ip地址连接(我认为feign客户端使用内部ip地址)。有没有办法解决这个问题,可能是启用容器通信或使用公共uri
编辑: 我设法通过改变主机名来获取公共网址。
eureka:
instance:
hostname: ${vcap.application.uris[0]}
但在eureka服务器中它注册为$ {vcap.application.uris [0]}:[随机端口](如xxxxxx.run.aws-usw02-pr.ice.predix.io:61142/yyy) 有没有办法删除该随机端口。
答案 0 :(得分:1)
我们已设法使用以下配置修复假装客户端问题,
eureka:
client:
serviceUrl:
defaultZone: https://someeurekaserver/eureka/
registerWithEureka: true
fetchRegistry: false
healthcheck:
enabled: true
instance:
hostname: ${vcap.application.application_uris[0]}
instanceId: ${spring.application.name}:${random.int}
secure-port: 443
non-secure-port: 443
secure-port-enabled: true
non-secure-port-enabled: false
preferIpAddress: false
leaseRenewalIntervalInSeconds: 10
home-page-url: https://${eureka.instance.hostname}:${eureka.instance.secure-port}
secure-virtual-host-name: https://${vcap.application.application_uris[0]}
重要性配置为secure-virtual-host-name: https://${vcap.application.application_uris[0]}
答案 1 :(得分:0)
目前无法为Predix Cloud Foundry中运行的应用程序分配特定端口。正如您所发现的,CF会分配一个随机端口,但这仅在CF环境中使用。任何其他微服务/客户端/应用程序应仅使用端口443进行HTTPS。所以,如果可能的话,也许你可以硬编码你的Eureka客户端以使用443。