1
votes

I'm setting up Spring Cloud on AWS ECS but I have a problem with Zuul/Eureka. When I'm trying to hit endpoint "/api/second/service2" I see this error:

Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: service2

I'm using Elastic IP for Eureka instance as explained here https://github.com/Netflix/eureka/wiki/Deploying-Eureka-Servers-in-EC2 . I have 2 spring boot applications, and I see both of them in Eureka. I'm able to hit endpoint directly. eureka

This is config for Eureka server:

server:
  port: 8761
eureka:
  client:
    fetchRegistry: false
    registerWithEureka: false
    eurekaServerURLContext: eureka
    region: eu-west-3
    eurekaServerPort: 8761
    useDnsForFetchingServiceUrls: true
    eurekaServerDNSName: my.dns
  datacenter: cloud

Service2:

spring:
  application:
    name: service2
server:
  port: 8882
eureka:
  datacenter: cloud
  instance:
    preferIpAddress: true
  client:
    fetchRegistry: true
    eurekaServerURLContext: eureka
    region: eu-west-3
    eurekaServerPort: 8761
    useDnsForFetchingServiceUrls: true
    eurekaServerDNSName: my.dns

Zuul:

pring:
  application:
    name: api-gateway
server:
  port: 8080
eureka:
  datacenter: cloud
  client:
    fetchRegistry: true
    eurekaServerURLContext: eureka
    region: eu-west-3
    eurekaServerPort: 8761
    useDnsForFetchingServiceUrls: true
    eurekaServerDNSName: my.dns

zuul:
  prefix: /api
  routes:
    first-service:
      path: /first/**
      serviceId: service1
    second-service:
      path: /second/**
      serviceId: service2

Do you have any idea where can be the problem?

EDIT: It works only if I map my service2 instance port from 8882 to port 80

1

1 Answers

0
votes

As I can see your service2 is not registered with eureka, like:

eureka:
  client:
    registerWithEureka: true

the rest of config is not needed, those are config for eureka server, and you shouldn't configure eureka server in any service, it is done in eureka service itself.

And it should fetch the registry, so in service2 you will have

spring:
  application:
    name: service2
server:
  port: 8882
eureka:
  client:
    registerWithEureka: true
    fetchRegistry: true

same goes for the rest of the services