阅读背景:

在Predix中假设客户端通信(Cloud Foundry)

来源:互联网 

I have 2 microservices built using Netflix eureka. They communicate using feign client. In my local environment feign client works without any issue. But in the Predix (a cloud foundry) environment they fail to communicate. Feign client always gives connection time out error. As found that feign client try to connect using instance ip address (I think feign client uses the internal ip address). Is there a way to fix this issue, may be enabling container communication or using public uri

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

EDIT: I managed to get the public url by changing hostname like below.

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

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

but in the eureka server it register as ${vcap.application.uris[0]}:[random port] (like xxxxxx.run.aws-usw02-pr.ice.predix.io:61142/yyy) is there a way to remove that random port.

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

2 个解决方案

#1


0  

There's currently no way to assign a specific port to an application running in Predix Cloud Foundry. CF assigns a random port, as you've discovered, but this is only used inside the CF environment. Any other microservice/client/application should only use port 443 for HTTPS. So, maybe you can hardcode your Eureka client to use 443, if possible.

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

#2


0  

We have managed to fix feign client issue using following configuration,

我们已设法使用以下配置修复假装客户端问题,

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

importance configuration is secure-virtual-host-name: https://${vcap.application.application_uris[0]}

重要性配置是secure-virtual-host-name:https:// $ {vcap.application.application_uris [0]}


分享到: