Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Feign Client communication in 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

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.

like image 442
Keaz Avatar asked Mar 19 '18 13:03

Keaz


1 Answers

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

like image 155
Keaz Avatar answered Sep 19 '22 21:09

Keaz