Spring Cloud Gateway instance unable to connect to eureka server - spring-boot

I'm following this "Microservices with Spring Boot and Spring Cloud" book by Magnus Larsson, at chapter 10 Spring Cloud Gateway is introduced as an edge server into the microservices landscape, once all the microservices are started SCGateway is unable to connect with the Eureka server:
RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://eureka:8761/eureka/}, exception=I/O error on POST request for "http://eureka:8761/eureka/apps/GATEWAY": Connect to eureka:8761 [eureka/172.23.0.4] failed: Connection refused; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to eureka:8761 [eureka/172.23.0.4] failed: Connection refused stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://eureka:8761/eureka/apps/GATEWAY": Connect to eureka:8761 [eureka/172.23.0.4] failed: Connection refused; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to eureka:8761 [eureka/172.23.0.4] failed: Connection refused...
this is the docker-compose.yml file:
version: '2.1'
services:
product:
...instance configuration
recommendation:
...instance configuration
review:
...instance configuration
product-composite:
...instance configuration
mongodb:
...instance configuration
mysql:
...instance configuration
rabbitmq:
...instance configuration
eureka:
build: spring-cloud/eureka-server
mem_limit: 512m
gateway:
environment:
- SPRING_PROFILES_ACTIVE=docker
build: spring-cloud/gateway
mem_limit: 512m
ports:
- "8085:8085"
Eureka Dockerfile:
FROM adoptopenjdk:16_36-jre-hotspot as builder
WORKDIR extracted
ADD ./build/libs/*.jar app.jar
RUN java -Djarmode=layertools -jar app.jar extract
FROM adoptopenjdk:16_36-jre-hotspot
WORKDIR application
COPY --from=builder extracted/dependencies/ ./
COPY --from=builder extracted/spring-boot-loader/ ./
COPY --from=builder extracted/snapshot-dependencies/ ./
COPY --from=builder extracted/application/ ./
EXPOSE 8761
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
Eureka application.yml file:
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
# from: https://github.com/spring-cloud-samples/eureka/blob/master/src/main/resources/application.yml
server:
waitTimeInMsWhenSyncEmpty: 0
response-cache-update-interval-ms: 5000
management.endpoints.web.exposure.include: "*"
Spring Cloud Gateway Dockerfile:
FROM adoptopenjdk:16_36-jre-hotspot as builder
WORKDIR extracted
ADD ./build/libs/*.jar app.jar
RUN java -Djarmode=layertools -jar app.jar extract
FROM adoptopenjdk:16_36-jre-hotspot
WORKDIR application
COPY --from=builder extracted/dependencies/ ./
COPY --from=builder extracted/spring-boot-loader/ ./
COPY --from=builder extracted/snapshot-dependencies/ ./
COPY --from=builder extracted/application/ ./
EXPOSE 8085
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
Spring Cloud Gateway application.yml file:
server.port: 8085
spring.application.name: gateway
app.eureka-server: localhost
eureka:
client:
serviceUrl:
defaultZone: http://${app.eureka-server}:8761/eureka/
initialInstanceInfoReplicationIntervalSeconds: 5
registryFetchIntervalSeconds: 5
instance:
leaseRenewalIntervalInSeconds: 5
leaseExpirationDurationInSeconds: 5
spring.cloud.gateway.routes:
- id: product-composite
uri: lb://product-composite
predicates:
- Path=/product-composite/**
- id: product-composite-swagger-ui
uri: lb://product-composite
predicates:
- Path=/openapi/**
- id: eureka-api
uri: http://${app.eureka-server}:8761
predicates:
- Path=/eureka/api/{segment}
filters:
- SetPath=/eureka/{segment}
- id: eureka-web-start
uri: http://${app.eureka-server}:8761
predicates:
- Path=/eureka/web
filters:
- SetPath=/
- id: eureka-web-other
uri: http://${app.eureka-server}:8761
predicates:
- Path=/eureka/**
management.endpoint.health.show-details: "ALWAYS"
management.endpoints.web.exposure.include: "*"
logging:
level:
root: INFO
org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator: INFO
org.springframework.cloud.gateway: TRACE
---
spring.config.activate.on-profile: docker
app.eureka-server: eureka
Originally the project uses Spring Boot version 2.5.2 and Spring Cloud version 2020.0.3, also tried with recent versions (with no success) such as:
Spring Boot version: 2.6.6 and 2.7.5
Spring Cloud: 2021.0.4
The Spring Cloud Gateway is always throwing the same exception:
org.apache.http.conn.HttpHostConnectException: Connect to eureka:8761
[eureka/172.23.0.4] failed: Connection refused
Trying to access the Eureka dashboard or http://localhost:8085/actuator/health endpoint hangs forever.
I'll appreciate any hints or help, thanks in advance.

Related

spring boot application properties not read correctly

For some reason it does not seem like application.yml is correctly read in my spring boot application. No matter what I try with the application tries to connect to eureka on local host.
spring:
application:
name: oneminute-dashboard
server:
port: 5001
eureka:
client:
service-url:
defaultZone: http://eureka-server:8761/eureka
sql:
init:
platform: postgres
datasource:
url: jdbc:postgresql://db:5432/dev_onemin_percent
username: xxxx
password: xxxx
jpa:
hibernate:
ddl-auto: update
database-platform: org.hibernate.dialect.PostgreSQLDialect
Looking at the log I see that it tries to connect to localhost. I have the same problem with postgres but there the datasource can be overridden from the docker-compose file.
oneminute_dashboard | 2022-08-02 10:09:58.069 WARN 1 --- [ restartedMain] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: I/O error on GET request for "http://localhost:8761/eureka/apps/": Connect to localhost:8761 [localhost/127.0.0.1] failed: Connection refused; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8761 [localhost/127.0.0.1] failed: Connection refused
oneminute_dashboard | 2022-08-02 10:09:58.069 INFO 1 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : DiscoveryClient_ONEMINUTE-DASHBOARD/01bd8154c292:oneminute-dashboard:5001 - was unable to refresh its cache! This periodic background refresh will be retried in 30 seconds. status = Cannot execute request on any known server stacktrace = com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
docker compose below
version: '3.8'
services:
oneminute_dashboard:
image: xyz/oneminute_dashboard:latest
container_name: oneminute_dashboard
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/dev_onemin_percent
ports:
- "5001:5001"
expose:
- 5001
networks:
- IB
depends_on:
- eureka-server
This documentation uses serviceUrl instead of service-url
https://cloud.spring.io/spring-cloud-static/Edgware.SR6/multi/multi__service_discovery_eureka_clients.html
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
It will be
default-zone: http://eureka-server:8761/eureka
and not
defaultZone: http://eureka-server:8761/eureka

Microservices can't fetch Spring Config Server data using docker in the same network?

I have microservices application, and i'm using Spring cloud and Spring boot v2.3 . i'm depending on config server and eureka, everything is working fine on my local machine from IDE, but when I deployed the stack on docker, my app Auth-Service cannot fetch from spring config server container, and give me the following stack trace
2020-07-05 02:23:52.888 INFO [auth-service,,,] 1 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-07-05 02:23:53.091 INFO [auth-service,,,] 1 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2020-07-05 02:23:53.092 WARN [auth-service,,,] 1 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/auth-service/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
I thought the issue is just waiting until or container-network as mentioned here Spring config is no accessible and this Microservices can't reach config service, but I ensured the containers are within same network, and to simulate, I started the config first, but got same error.
Here are the configurations i'm using
version: '3.8'
services:
eureka-service:
build:
context: ./eureka
image: eureka-service:latest
container_name: eureka
ports:
- 8761:8761
hostname: eureka
networks:
- mynetwork
config-service:
build:
context: ./configServer
image: config-server:latest
ports:
- 8888:8888
networks:
- mynetwork
proxy-service:
build:
context: ./web-cv-proxy
image: zuul-service:latest
ports:
- 8081:8081
depends_on:
- config-service
networks:
- mynetwork
auth-service:
build:
context: ./web-based-cv/auth-service
image: auth-service:latest
ports:
- 8060:8060
depends_on:
- config-service
- eureka-service
restart: on-failure
networks:
- mynetwork
portal-service:
build:
context: ./web-based-cv/cv-portal
image: cv-portal:latest
ports:
- 9090:9090
depends_on:
- config-service
- eureka-service
restart: on-failure
networks:
- mynetwork
networks:
mynetwork:
driver: bridge
Config server docker file
FROM java:openjdk-8-alpine
LABEL version="1.0"
LABEL description="configuration server"
COPY ./target/configServer-0.0.1-SNAPSHOT.jar ./
EXPOSE 8888
CMD ["java", "-jar", "configServer-0.0.1-SNAPSHOT.jar"]
Application docker file
FROM java:openjdk-8-alpine
LABEL version="1.0"
LABEL description="cv authintication service"
COPY ./target/auth-service-1.0.0-exec.jar auth-service-1.0.0-exec.jar
EXPOSE 8060
CMD ["java", "-jar", "/auth-service-1.0.0-exec.jar"]
The application bootstrap file
spring:
datasource:
jpa:
properties:
hibernate:
format_sql: true
ddl-auto: none
application:
name: auth-service
bus:
refresh:
enabled: true
profiles:
active: jdbc
cloud:
retry:
initial-interval: 1500
multiplier: 1.5
max-attempts: 10000
max-interval: 1000
server:
servlet:
context-path: /api/auth
port: 8060
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
register-with-eureka: true
fetch-registry: true
instance:
prefer-ip-address: true
management:
endpoints:
web:
exposure:
include: ["health","info","refresh", "bus-refresh"]
Your advice is highly appreciated , and thanks in advance.
Remember one thing, when you deploy your micro-services on docker,
localhost won't work there as your micoservices run in a container
within a different virtual network. So it won't be identified using
localhost.
So in your docker compose file, you have to provide the name of your
the service of your Eureka server.
For example -
services:
discovery:
image: <Eureka server image name>
ports:
- 8761:8761
ConfigServerService:
image: <Config server image name>
environment:
- JAVA_OPTS=
-DEUREKA_SERVER=http://discovery:8761/eureka
depends_on:
- discovery
links:
- discovery
ports:
- 8888:8888
Microservice1:
image: <Microservice1 image name>
environment:
- JAVA_OPTS=
-DEUREKA_SERVER=http://discovery:8761/eureka
depends_on:
- discovery
- ConfigServerService
links:
- discovery
- ConfigServerService
ports:
- 8000:8000
You need to change auth-service configuration from localhost:8888 to http://config-service:8888, as the error seems not getting the correct endpoint.
docker-compose networking
error on GET request for "http://localhost:8888/auth-service/default": Connection refused (Connection refused);
localhost:8888 means this container (auth-service) not the spring config server.
For some reason my containers didn't be able to connect using direct uri configuration, although I added them to the same network.
I solved the issue with depending on Eureka itself, and connecting to Spring config through eureka discovery with the following config in client apps
spring
config:
discovery:
enabled: true
service-id: configServer
I think it is a good way to give the control to eureka, but I hoped i would know why it didn't work with uri instead? by the way this way will give me more flexibility if I deployed on several clusters.

Spring Cloud Config in Docker container is not accessible

I have a relatively simple setup. A Spring Could Config server, and a Spring Cloud Eureka server. (I refer Eureka server as Discover everywhere in my config...) The config server uses a Git repository for finding the appropriate config.
Everything is in Docker containers. I use docker-compose to build my services. The Gateway server should wait for config server to come up. I'll provide the source of the file further down.
So, when I build and start the containers, the discovery (Eureka) server doesn't want to come up. It exits with an exception. It is really long, so I just add the most important part here:
019-01-27 23:52:17,494 [INFO ] o.s.c.c.c.ConfigServicePropertySourceLocator.getRemoteEnvironment [main] – Fetching config from server at : http://tao-elszamolas-config:9001
2019-01-27 23:52:17,898 [INFO ] o.s.c.c.c.ConfigServicePropertySourceLocator.getRemoteEnvironment [main] – Connect Timeout Exception on Url - http://tao-elszamolas-config:9001. Will be trying the next url if available
2019-01-27 23:52:17,902 [ERROR ] o.s.b.SpringApplication.reportFailure [main] – Application run failed
java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
... Something...Something
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://tao-elszamolas-config:9001/discovery-server/prod": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:743) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:578) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:218) ~[spring-cloud-config-client-2.1.0.RC3.jar!/:2.1.0.RC3]
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:96) ~[spring-cloud-config-client-2.1.0.RC3.jar!/:2.1.0.RC3]
... 15 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) ~[?:?]
at java.net.Socket.connect(Socket.java:591) ~[?:?]
at java.net.Socket.connect(Socket.java:540) ~[?:?]
at sun.net.NetworkClient.doConnect(NetworkClient.java:182) ~[?:?]
at sun.net.www.http.HttpClient.openServer(HttpClient.java:474) ~[?:?]
at sun.net.www.http.HttpClient.openServer(HttpClient.java:569) ~[?:?]
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) ~[?:?]
at sun.net.www.http.HttpClient.New(HttpClient.java:341) ~[?:?]
at sun.net.www.http.HttpClient.New(HttpClient.java:362) ~[?:?]
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1242) ~[?:?]
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1181) ~[?:?]
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1075) ~[?:?]
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1009) ~[?:?]
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:734) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:578) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:218) ~[spring-cloud-config-client-2.1.0.RC3.jar!/:2.1.0.RC3]
at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:96) ~[spring-cloud-config-client-2.1.0.RC3.jar!/:2.1.0.RC3]
... 15 more
The only exception what I found in the Config server log is the one complaining about the connection to Discovery (Eureka) server. Yes, I try to register my config service inEureka for looking it up at startup of further microservices.
The connection is refused which means, the config server is not running at the time when Eureka server is trying to get its config or it is not listening on the given port, 9001.
How is it possible? I used the depends_on in my compose file, so it should wait for that.
Or why it finishes working? If I do the same thing on local without docker then it keeps trying to connect to Config, until the config server starts up. I'd like achieve the same behaviour using Docker.
Any advice would be appreciated!
And finally here are my config files:
docker-compose.yml:
version: "3"
services:
tao-elszamolas-config:
build: ./tao-elszamolas-config
container_name: tao-elszamolas-config
ports:
- "9001:9001"
volumes:
- "/tao-elszamolas/logs:/var/log/tao-elszamolas"
networks:
- taonetwork
tao-elszamolas-discovery:
build: ./tao-elszamolas-discovery
container_name: tao-elszamolas-discovery
depends_on:
- tao-elszamolas-config
ports:
- "9002:9002"
volumes:
- "/tao-elszamolas/logs:/var/log/tao-elszamolas"
networks:
- taonetwork
networks:
taonetwork:
driver: bridge
Dockerfile of Config Server:
FROM openjdk:11-jdk-slim
MAINTAINER BeszterceKK
COPY ./tao-elszamolas-config.jar /usr/src/taoelszamolas/tao-elszamolas-config.jar
WORKDIR /var/log/tao-elszamolas
WORKDIR /usr/src/taoelszamolas
ENV SPRING_PROFILES_ACTIVE prod
EXPOSE 9001
ENTRYPOINT ["java", "-DlogFileLocation=/var/log/tao-elszamolas", "-jar", "tao-elszamolas-config.jar"]
application.yml for Config server:
server:
port: 9001
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://github.com/something/something
username: something
password: something
skip-ssl-validation: true
security:
user:
name: something
password: something
eureka:
client:
serviceUrl:
defaultZone: http://something:something#tao-elszamolas-discovery:9002/eureka/
info:
artifact: tao-elszamolas-config
name: TAO Elszamolas Config Application
description: Tao elszamolas microservice elosztott szolgaltatas konfiguracio
version: 1.0.0
Dockerfile of Discovery (Eureka) Server:
FROM openjdk:11-jdk-slim
MAINTAINER BeszterceKK
COPY ./tao-elszamolas-discovery.jar /usr/src/taoelszamolas/tao-elszamolas-discovery.jar
WORKDIR /var/log/tao-elszamolas
WORKDIR /usr/src/taoelszamolas
ENV SPRING_PROFILES_ACTIVE prod
EXPOSE 9002
ENTRYPOINT ["java", "-DlogFileLocation=/var/log/tao-elszamolas", "-jar", "tao-elszamolas-discovery.jar"]
bootstrap.yml for Discovery (Eureka) server:
spring:
application:
name: discovery-server
cloud:
config:
fail-fast: true
name: discovery-server
uri: http://tao-elszamolas-config:9001
username: something
password: something
application.yml for Discovery (Eureka) server:
server:
port: 9002
eureka:
instance:
hostname: tao-elszamolas-discovery
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://tao-elszamolas-discovery:9002/eureka
info:
artifact: tao-elszamolas-discovery
name: TAO Elszamolas Eureka Szolgaltatas monitor
description: Tao elszamolas automatikus szolgaltatas regisztracio
version: 1.0.0
And finally, this is how I start my containers. It is simply:
docker-compose up -d
The whole application stack works on local without Docker. So I guess the problem is with my Docker configuration.
One more thing to mention, generally, I don't want to publish the ports to host, only expose them on my custom network between the containers. This is why I tried to replace the PORTS with EXPOSE, but it didn't really help.
for startup Compose does not wait until a container is “ready” (whatever that means for your particular application) - only until it’s running
So, you should refer : https://docs.docker.com/compose/startup-order/
for wait until for config server container is ready first (already listened on port 9001), then starting Eureka server container.
You registry service try to start before configuration service is up. You have to force him to wait.
You can do it with condition: service_started, like below. But I think it is not working with version 3
version: '2.1'
# ...
tao-elszamolas-discovery:
build: ./tao-elszamolas-discovery
container_name: tao-elszamolas-discovery
depends_on:
- tao-elszamolas-config:
condition: service_started
ports:
- "9002:9002"
volumes:
- "/tao-elszamolas/logs:/var/log/tao-elszamolas"
networks:
- taonetwork
A solution for version 3 is to use healthcheck and restart: on-failure
Take a look at this post
Another solution is to use entrypoint section to launch a batch file at start which is pinging configuration service container while it is not responding.

Eureka, ZUUL, Docker Compose on bridge network java.net.ConnectException: Connection refused

I'm running a Zuul service and Eureka service on separate docker containers with minimalistic configurations (both are spring boot projects).
Eureka:
docker-compose.xml:
version: '2'
services:
app:
build:
context: ./
image: eureka
environment:
eureka.client.serviceUrl.defaultZone: http://eurekaserver_app_1:8070/eureka/
tty: false
network_mode: bridge
ports:
- 8070:8070
DockerFile:
FROM java:8
COPY ./build/libs/eureka-server-0.0.1-SNAPSHOT.jar /usr/src/eureka/
WORKDIR /usr/src/eureka
EXPOSE 8070
CMD ["java","-jar","eureka-server-0.0.1-SNAPSHOT.jar"]
Zuul:
docker-compose.xml:
version: '2'
services:
app:
build:
context: ./
image: zuul-service
environment:
eureka.client.serviceUrl.defaultZone: http://eurekaserver_app_1:8070/eureka/
tty: false
ports:
- 8069:8069
network_mode: bridge
DockerFile:
FROM java:8
COPY ./build/libs/zuul-service-0.0.1-SNAPSHOT.jar /usr/src/item/
WORKDIR /usr/src/item
EXPOSE 8069
ENTRYPOINT ["java","-jar","zuul-service-0.0.1-SNAPSHOT.jar"]
I used the network ls --no-trunc Docker command to make sure they are not spinning up a new network:
NETWORK ID NAME DRIVER SCOPE
ba216f3e01bb168848074a99875666fe382a4eda15daad0c428a8102707ee49f bridge bridge local
a63a8adf0fd162d9b99bdf77bc4a13c0bfcfb8a9aca3c5375e60d5df5c5e305d host host local
2debbe96f8a96fdd8d6da983877609e0bdb7a1df6b25537f35f1608de0739fc7 none null local
Which seems alright, The problem is that Eureka container starts up properly, however zuul-service isn't when I used docker-compose up. It throws:
com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)
app_1 | at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
app_1 | at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar!/:1.19.1]
app_1 | at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.8.6.jar!/:1.8.6]
app_1 | at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar!/:1.19.1]
app_1 | at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar!/:1.19.1]
app_1 | at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar!/:1.19.1]
app_1 | at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) ~[jersey-client-1.19.1.jar!/:1.19.1]
app_1 | at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.getApplicationsInternal(AbstractJerseyEurekaHttpClient.java:194) ~[eureka-client-1.8.6.jar!/:1.8.6]
I am quite unsure on what I could be missing here?
The official Docker Compose docamantation says:
By default Compose sets up a single network for your app. Each
container for a service joins the default network and is both
reachable by other containers on that network, and discoverable by
them at a hostname identical to the container name.
I suggest you to create one docker-compose.yaml file for both applications, properly name them and separate Dockerfiles to different folders:
version: '2'
services:
eureka:
build:
context: ./eureka/
image: eureka
environment:
eureka.client.serviceUrl.defaultZone: http://eureka:8070/eureka/
tty: false
ports:
- 8070:8070
zuul:
build:
context: ./zuul/
image: zuul-service
environment:
eureka.client.serviceUrl.defaultZone: http://eureka:8070/eureka/
tty: false
ports:
- 8069:8069
When containers are up, they will be able to communicate between each other by eureka:8070 and zuul:8069 accordingly.

Spring-Cloud on Weblogic 12.1.2

We have developed Spring-boot microservices with NetFlix OSS/Spring-cloud. In the development environment, we are running with embedded tomcat, it works well.
Now I'm trying to deploy on Weblogic 12.1.2, I'm able to deploy service registry and API-Gateway inside two different managed servers. But When I open Eureka server page, API-Gateway is not registered with the Service Registry.
Service-Registry application.yml
spring:
application:
name: service-registry
server:
port: 61001
eureka:
client:
register-with-eureka: false
fetch-registry: false
api-gateway application.yml
spring:
application:
name: api-gateway
cloud:
loadbalancer:
retry:
enabled: true
# Ribbon - Client side load balancer
ribbon:
ReadTimeout : 60000
ConnectTimeout: 60000
server:
port: 61002
context-path: /nasw
eureka:
client:
serviceUrl:
defaultZone: http://<ipAdr>:61001/eureka/
# instance:
# instanceId:
### Zuul - Router/Filter/Reverse Proxy
zuul:
ignoredServices: '*'
host:
connect-timeout-millis: 100000
socket-timeout-millis: 600000
routes:
network-planning: "**/network-planning/**"
network-schemagen: "**/network-schemagen/**"
network-verification: "**/network-verification/**"
nw-netgeoview-nw-tracer: "**/nw-netgeoview-nw-tracer/**"
### Hystrix - Circuit Breaker/Fault&Latency Tolerant
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 600000
timeout:
enabled: false
isolation:
strategy: SEMAPHORE
Service registry home page
Could you please help me with following queries?
Is it possible to deploy Spring-Cloud on Weblogic 12.1.2?
Is it a correct way to deploy each microservice in a separate managed server?
If Yes, Am I missing any configuration so that api-gateway can register with service-registry?

Resources