Feign Client communication in predix (Cloud Foundry)

531 views Asked by At

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

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.

2

There are 2 answers

4
gstroup On BEST ANSWER

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.

0
Keaz On

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