Open GIRISHARAN opened 1 month ago
Hello @GIRISHARAN have you mapped your docker port to local port? Have you properly set eureka.client.serviceUrl.defaultZone
?
Hello @OlgaMaciaszek Yes, I mapped the docker port to my local port. In my git I have properly set eureka.client.serviceUrl.defaultZone. My CloudConfig server is able to get details from my git repo and register itself with Eureka Server but other services which has to get the configuration details from CloudConfig server are not able to fetch details from it.
@GIRISHARAN you are getting a ConnectionRefused
; it seems something is misconfigured in your docker environment, especially as the apps work normally while on a different enviroment. It's difficult to know the issue without access to the environment.
@GIRISHARAN you can use env variables in your configuration for the services something like this -eureka.client.serviceUrl.defaultZone=http://${EUREKA_HOST:localhost}:8761/eureka
If present in the context the value of EUREKA_HOST
will be taken else default will be localhost.
You can pass the hostname for your eureka server you can set custom hostname for your eureka service using
hostname: eureka-server
in your docker configuration.
@ansh-devs the issue I am facing now is my services (dept, user) are not able to connect with Cloud Config Server even though I have mentioned configuration details correctly in my application.properties file of that services
spring.cloud.config.import-check.enabled=false spring.cloud.config.enabled=true spring.cloud.config.uri=http://CLOUD-CONFIG-SERVER:8083
CLOUD-CONFIG-SERVER is the name of my Docker Container
@GIRISHARAN try using env variables as i mentioned,
then explicitly assign hostname to your config server container like - hostname: {your_custom_hostname}
in your docker compose file...
I am using spring boot, spring cloud netfix eureka-server, config-server and docker to run microservices.
Everything is fine in non-dockerized environments, but once I dockerized the eureka server and the microservice, for example user-service, I found that the user-service could not registered to eureka server but able to ping using "curl http://netflix-eureka-service-registry:8761".
My config-server is able to get details from my git repo where I am bale to see using /actuator/default
2024-05-21 18:39:25 2024-05-21T21:39:25.139Z INFO 1 --- [cloud-config-server] [freshExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to http://localhost:8761 [localhost/127.0.0.1] failed: Connection refused stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to http://localhost:8761 [localhost/127.0.0.1] failed: Connection refused 2024-05-21 18:39:25 at org.springframework.web.client.RestTemplate.createResourceAccessException(RestTemplate.java:915) 2024-05-21 18:39:25 at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:895) 2024-05-21 18:39:25 at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:790) 2024-05-21 18:39:25 at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:672) 2024-05-21 18:39:25 at org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient.getApplicationsInternal(RestTemplateEurekaHttpClient.java:145) 2024-05-21 18:39:25 at org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient.getApplications(RestTemplateEurekaHttpClient.java:135) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:121) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:80) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:120) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) 2024-05-21 18:39:25 at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) 2024-05-21 18:39:25 at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:1045) 2024-05-21 18:39:25 at com.netflix.discovery.DiscoveryClient.fetchRegistry(DiscoveryClient.java:958) 2024-05-21 18:39:25 at com.netflix.discovery.DiscoveryClient.refreshRegistry(DiscoveryClient.java:1475) 2024-05-21 18:39:25 at com.netflix.discovery.DiscoveryClient$CacheRefreshThread.run(DiscoveryClient.java:1442) 2024-05-21 18:39:25 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) 2024-05-21 18:39:25 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 2024-05-21 18:39:25 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) 2024-05-21 18:39:25 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 2024-05-21 18:39:25 at java.base/java.lang.Thread.run(Thread.java:833) 2024-05-21 18:39:25 Caused by: org.apache.hc.client5.http.HttpHostConnectException: Connect to http://localhost:8761 [localhost/127.0.0.1] failed: Connection refused
Getting this error for all my microservices (api-gateway, user-service, department-service, config-server)
In my git I have this- eureka.client.register-with-eureka=true eureka.client.fetch-registry=true eureka.client.service-url.defaultZone=http://netflix-eureka-service-registry:8761/eureka/
eureka.instance.hostname=netflix-eureka-service-registry
I tried all posible waus but did not find the issue. I kindly request anyone who can help me. I am learning spring microservices.