jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

No connection between gateway and eureka #18839

Closed paris0120 closed 2 years ago

paris0120 commented 2 years ago
Overview of the issue

It seems that the gateway server cannot connect to the Eureka server out of jdl generator.

Motivation for or Use Case

Generate microservice with gateway and microservice

Reproduce the error

Generated a gateway server and microservice server.
Started gateway server with docker-compose -f src/main/docker/app.yml up

I got

ERROR 1 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GATEWAY/gateway:139fa15be5b04239ff7a0dd2a823ac7e - was unable to send heartbeat!

Also, Eureka doesn't list the gateway server.

If I start a microservice with mvn, the Eureka can show the microservice but not the gateway. Also if I try to accesss the API of microservice from the gate server I get

{"type":"https://www.jhipster.tech/problem/problem-with-message","title":"Unauthorized","status":401,"detail":"Not Authenticated","path":"/api/issues","message":"error.http.401"}

The following is my app.yml

This configuration is intended for development purpose, it's your responsibility to harden it for production

version: '3.8' services: gateway-app: image: gateway environment:

Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
vishal423 commented 2 years ago

Can you try changing localhost-config with docker-config in this line and try? - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS=file:./central-config/localhost-config/

paris0120 commented 2 years ago

Can you try changing localhost-config with docker-config in this line and try? - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS=file:./central-config/localhost-config/

The dock image works now but other microservice can't connect to Eureka now. I get the following message with microservice.

Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://admin:admin@jhipster-registry:8761/eureka/}, exception=I/O error on GET request for "http://admin:admin@jhipster-registry:8761/eureka/apps/": No such host is known (jhipster-registry); nested exception is java.net.UnknownHostException: No such host is known (jhipster-registry) stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://admin:admin@jhipster-registry:8761/eureka/apps/": No such host is known (jhipster-registry); nested exception is java.net.UnknownHostException: No such host is known (jhipster-registry)

vishal423 commented 2 years ago

You can try adding an entry into your hosts config to map jhipster-registry with 127.0.0.1 for micro-services connection issue.

DanielFran commented 2 years ago

Closing, since doubts have been answered