1

I have a couple of microservices on Heroku - eureka-server, Zuul server and some app services.

While I am trying to reach any of my services, for example, "service1" via Zuul gateway, Zuul is unable to forward the request to the respective service (when I'm trying to run them locally everything works fine). I've found the following errors in Zuul logs:

com.netflix.zuul.exception.ZuulException: Forwarding error 
Caused by: com.netflix.client.ClientException: Load balancer does not have the available server for the client: service1

Below are configurations of my services:

1) "zuul server" application.yml

server:
  port: ${PORT:8000}

zuul:
  prefix: /api
  ignoredServices: '*'
  routes:
    service1:
      path: /path_for_service1/**
      serviceId: service1
      strip-prefix: false
   ...

management:
  endpoints:
    web:
      exposure:
        include: "*"

eureka:
  client:
    serviceUrl:
      defaultZone: ${EUREKA_URL:http://localhost:5000}/eureka/

2) "eureka server" application.yml

server:
  port: ${PORT:5000}

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

3.1) "service1" application.yml

server.port=${PORT:8081}
eureka.client.service-url.defaultZone=${EUREKA_URL:http://localhost:5000}/eureka/

3.2) "service1" bootstrap.yml

spring:
  application:
    name: service1

All microservices are visible in eureka dashboard.

If I change zuul routes to hard-coded url it works well but it is not what I'm looking for.

zuul:
  prefix: /api
  ignoredServices: '*'
  routes:
    service1:
      path: /path_for_service1/**
      url: http://url_of_service_1
      strip-prefix: false

Could you please help me with this issue?

StarReider
  • 53
  • 8

1 Answers1

1

Finally, I've found root cause :) All services are registered in eureka using heroku hostname by default (like "085930c7-b893-4b34-88a7-6e37fbe7fa0f") which is not accessible outside. But services are accessible by domain names. So I just added domain name settings to application.properties of each service (https://blog.heroku.com/managing_your_microservices_on_heroku_with_netflix_s_eureka)

eureka:
  instance:
    non-secure-port: 80
    hostname: ${DOMAIN_NAME}

and now it works.

StarReider
  • 53
  • 8