7

我有 2 个使用 Netflix eureka 构建的微服务。他们使用假客户端进行通信。在我的本地环境中,假装客户端可以正常工作。但在 Predix(云代工厂)环境中,它们无法通信。Feign 客户端总是给出连接超时错误。发现 feign 客户端尝试使用实例 ip 地址进行连接(我认为 feign 客户端使用内部 ip 地址)。有没有办法解决这个问题,可能是启用容器通信或使用公共 uri

编辑:我设法通过更改主机名来获取公共网址,如下所示。

eureka:
 instance:
  hostname: ${vcap.application.uris[0]}

但在尤里卡服务器它注册为 ${vcap.application.uris[0]}:[random port] (如 xxxxxx.run.aws-usw02-pr.ice.predix.io:61142/yyy)有没有办法删除该随机端口。

4

2 回答 2

1

我们已经设法使用以下配置修复了 feign 客户端问题,

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]}

于 2018-05-02T04:38:35.447 回答
0

目前无法将特定端口分配给在 Predix Cloud Foundry 中运行的应用程序。正如您所发现的,CF 分配了一个随机端口,但这仅在 CF 环境中使用。任何其他微服务/客户端/应用程序都应仅将端口 443 用于 HTTPS。所以,如果可能的话,也许你可以硬编码你的 Eureka 客户端以使用 443。

于 2018-03-28T15:52:19.823 回答