7

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.

Keaz
  • 955
  • 1
  • 11
  • 21
  • Can you provide some more information, please? Are you running the feign client in Predix? Where are your other 2 microservices running? Microservices running in Predix cloud should not be referenced by IP address, as the IP changes often. – gstroup Mar 20 '18 at 17:40
  • @gstroup Sorry about the delayed reply. yes all the microservices and feign clients are running in predix. And I managed to fix IP address issue. (see the edited post). But apps are still register with random port. – Keaz Mar 26 '18 at 13:07

2 Answers2

1

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

Keaz
  • 955
  • 1
  • 11
  • 21
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.

gstroup
  • 1,064
  • 8
  • 16
  • yes I hardcode the client port to 443, but app fail to start. I think 443 post is not exposed in the container. – Keaz Apr 02 '18 at 16:57
  • Sorry, I might have confused you. So your client will access the other services over 443. But internally, CF will assign a different port to your client. So that's why you can't hardcode the client (or any microservice to use a specific port.) You should configure your client to communicate with other CF microservices over 443. – gstroup Apr 05 '18 at 21:56
  • Is there a way we can enable internal communication between containers by using container ip and port. Because now CF assign container port. – Keaz Apr 11 '18 at 04:13
  • we are managed set the port to 80 using below changes hostname: ${vcap.application.application_uris[0]} instanceId: ${spring.application.name}:${random.int} secure-port-enabled: false non-secure-port-enabled: true secure-port: 443 non-secure-port: 80 health-check-url: https://${eureka.instance.hostname}:${eureka.instance.non-secure-port}/health status-page-url: https://${eureka.instance.hostname}:${eureka.instance.non-secure-port}/info home-page-url: https://${eureka.instance.hostname}:${eureka.instance.non-secure-port} preferIpAddress: false – Keaz Apr 25 '18 at 07:23