0

In the case of a JHipster microservices architecture, I run an UAA server named AuthServer in a docker container and the Jhipster registry in another container.

The docker containers run in the same user-bridge network configuration.

As the registry is not in the same container, I configured my UAA server to connect to jhipster-registry machine in my application.yml file

eureka:
instance:
    prefer-ip-address: true
client:
    service-url:
        defaultZone: http://admin:${jhipster.registry.password}@jhipster-registry:8761/eureka/

The same way, I used this in the bootstrap.yml file :

spring:
cloud:
    config:
        fail-fast: true
        retry:
            initial-interval: 1000
            max-interval: 2000
            max-attempts: 100
        uri: http://admin:${jhipster.registry.password}@jhipster-registry:8761/config

And finally in my docker-compose file, I also used

version: '3.3'
services:
    authserver-app:
        image: authserver
        environment:
            - _JAVA_OPTIONS=-Xmx512m -Xms256m
            - SPRING_PROFILES_ACTIVE=prod,swagger
            - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
            - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
            - SPRING_DATASOURCE_URL=jdbc:postgresql://authserver-postgresql:5432/AuthServer
            - JHIPSTER_SLEEP=10 # gives time for the JHipster Registry to boot before the application

But when I start the application AuthServer, it keeps on trying to connect to localhost

authserver-app_1         | 2019-01-04 18:07:39.134 DEBUG 1 --- [  restartedMain] c.n.d.s.r.aws.ConfigClusterResolver      : Config resolved to [AwsEndpoint{ serviceUrl='http://admin:admin@localhost:8761/eureka/', region='us-east-1', zone='defaultZone'}]
authserver-app_1         | 2019-01-04 18:07:39.141 DEBUG 1 --- [  restartedMain] c.n.d.s.r.a.ZoneAffinityClusterResolver  : Local zone=defaultZone; resolved to: [AwsEndpoint{ serviceUrl='http://admin:admin@localhost:8761/eureka/', region='us-east-1', zone='defaultZone'}]

Where does this configuration about localhost come from and how can I fix it?

Frédéric Praca
  • 1,620
  • 15
  • 29
  • The registry is both an Eureka server and a Spring Cloud Config server. In `bootstrap.yml`, you have configured a client for the spring config server so that your clients can retrieve their config but have you modified the `*.yml`files in registry's central config? See https://www.jhipster.tech/jhipster-registry/ – Gaël Marziou Jan 05 '19 at 08:44
  • I'm not in front of the machine but I can only tell that I used the central configuration for docker execution as it only mentions jhipster-registry as host instead of localhost. – Frédéric Praca Jan 05 '19 at 11:20
  • OK, check it when you can and share git repos if it still doesn't work. – Gaël Marziou Jan 05 '19 at 18:59
  • I finally found by just reading the README.md :) The application.yml file in the docker-config directory should be used when app and registry are both in the same container. So I just had to switch to the application.yml from the localhost-config and edit it to change localhost to jhipster-registry. I must say that it stays obscure to me as the two application.yml are now strictly the same :D – Frédéric Praca Jan 07 '19 at 08:30

0 Answers0