Error 500 on spring cloud gateway finishConnect(..) on Heroku - spring-boot

I use Eureka with spring boot£. 1 server, 1 gateway, and 2 api, in my localhost i have no problems but when i deploy it on Heroku i can't reach an api through the api gateway. The EUREKA server discover all my services with no issues.
In the log of the gateway i have an ERROR 500
2022-11-22T14:23:30.428847+00:00 app[web.1]: 2022-11-22 14:23:30.428 INFO 4 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2022-11-22T14:23:30.666161+00:00 app[web.1]: 2022-11-22 14:23:30.665 INFO 4 --- [ main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses RestTemplate.
2022-11-22T14:23:31.365410+00:00 app[web.1]: 2022-11-22 14:23:31.365 WARN 4 --- [ main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production.You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2022-11-22T14:23:31.391840+00:00 app[web.1]: 2022-11-22 14:23:31.391 INFO 4 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2022-11-22T14:23:31.467468+00:00 app[web.1]: 2022-11-22 14:23:31.465 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2022-11-22T14:23:31.473095+00:00 app[web.1]: 2022-11-22 14:23:31.472 INFO 4 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2022-11-22T14:23:31.498500+00:00 app[web.1]: 2022-11-22 14:23:31.498 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2022-11-22T14:23:31.498507+00:00 app[web.1]: 2022-11-22 14:23:31.498 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2022-11-22T14:23:31.498541+00:00 app[web.1]: 2022-11-22 14:23:31.498 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2022-11-22T14:23:31.498575+00:00 app[web.1]: 2022-11-22 14:23:31.498 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2022-11-22T14:23:31.498609+00:00 app[web.1]: 2022-11-22 14:23:31.498 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2022-11-22T14:23:31.498651+00:00 app[web.1]: 2022-11-22 14:23:31.498 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2022-11-22T14:23:31.498691+00:00 app[web.1]: 2022-11-22 14:23:31.498 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2022-11-22T14:23:32.651073+00:00 app[web.1]: 2022-11-22 14:23:32.650 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2022-11-22T14:23:32.657211+00:00 app[web.1]: 2022-11-22 14:23:32.656 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2022-11-22T14:23:32.661123+00:00 app[web.1]: 2022-11-22 14:23:32.660 INFO 4 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2022-11-22T14:23:32.668470+00:00 app[web.1]: 2022-11-22 14:23:32.668 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1669127012667 with initial instances count: 1
2022-11-22T14:23:32.670420+00:00 app[web.1]: 2022-11-22 14:23:32.670 INFO 4 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application API-GATEWAY with eureka with status UP
2022-11-22T14:23:32.671101+00:00 app[web.1]: 2022-11-22 14:23:32.670 INFO 4 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1669127012670, current=UP, previous=STARTING]
2022-11-22T14:23:32.673386+00:00 app[web.1]: 2022-11-22 14:23:32.673 INFO 4 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_API-GATEWAY/api-gateway:21401: registering service...
2022-11-22T14:23:32.751146+00:00 app[web.1]: 2022-11-22 14:23:32.750 INFO 4 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_API-GATEWAY/api-gateway:21401 - registration status: 204
2022-11-22T14:23:33.561901+00:00 heroku[web.1]: State changed from starting to up
2022-11-22T14:23:33.486111+00:00 app[web.1]: 2022-11-22 14:23:33.485 INFO 4 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port 21401
2022-11-22T14:23:33.488877+00:00 app[web.1]: 2022-11-22 14:23:33.488 INFO 4 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 21401
2022-11-22T14:23:33.526112+00:00 app[web.1]: 2022-11-22 14:23:33.525 INFO 4 --- [ main] com.medhead.gateway.GatewayApplication : Started GatewayApplication in 13.001 seconds (JVM running for 13.623)
2022-11-22T14:23:35.370016+00:00 heroku[router]: at=info method=GET path="/" host=headmed-gateway.herokuapp.com request_id=cd66391f-2d15-4701-b0f9-c60c5c3f4b89 fwd="92.158.60.103" dyno=web.1 connect=0ms service=146ms status=404 bytes=387 protocol=https
2022-11-22T14:24:32.698383+00:00 heroku[router]: at=info method=GET path="/" host=headmed-gateway.herokuapp.com request_id=e5da2cfa-990f-4cab-ac75-b8e63ba6960e fwd="92.158.60.103" dyno=web.1 connect=0ms service=11ms status=404 bytes=387 protocol=https
2022-11-22T14:24:48.125828+00:00 heroku[router]: at=info method=GET path="/actuator/health" host=headmed-gateway.herokuapp.com request_id=84a74ade-2e24-4b00-a2ba-e87e23979557 fwd="92.158.60.103" dyno=web.1 connect=0ms service=51ms status=200 bytes=133 protocol=https
2022-11-22T14:25:37.041666+00:00 heroku[router]: at=info method=GET path="/patient-service/patients" host=headmed-gateway.herokuapp.com request_id=41c71d85-f335-494c-9b2d-119ee858a606 fwd="92.158.60.103" dyno=web.1 connect=0ms service=223ms status=500 bytes=411 protocol=https
2022-11-22T14:25:37.038507+00:00 app[web.1]: 2022-11-22 14:25:37.037 ERROR 4 --- [or-http-epoll-8] a.w.r.e.AbstractErrorWebExceptionHandler : [1a0ff15a-4] 500 Server Error for HTTP GET "/patient-service/patients"
2022-11-22T14:25:37.038521+00:00 app[web.1]:
2022-11-22T14:25:37.038522+00:00 app[web.1]: io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:6115
2022-11-22T14:25:37.038523+00:00 app[web.1]: Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
2022-11-22T14:25:37.038525+00:00 app[web.1]: Error has been observed at the following site(s):
2022-11-22T14:25:37.038527+00:00 app[web.1]: *__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
2022-11-22T14:25:37.038528+00:00 app[web.1]: *__checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
2022-11-22T14:25:37.038529+00:00 app[web.1]: *__checkpoint ⇢ HTTP GET "/patient-service/patients" [ExceptionHandlingWebHandler]
2022-11-22T14:25:37.038530+00:00 app[web.1]: Original Stack Trace:
2022-11-22T14:25:37.038530+00:00 app[web.1]: Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
2022-11-22T14:25:37.038531+00:00 app[web.1]: at io.netty.channel.unix.Errors.newConnectException0(Errors.java:155) ~[netty-transport-native-unix-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038531+00:00 app[web.1]: at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128) ~[netty-transport-native-unix-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038531+00:00 app[web.1]: at io.netty.channel.unix.Socket.finishConnect(Socket.java:359) ~[netty-transport-native-unix-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038533+00:00 app[web.1]: at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038533+00:00 app[web.1]: at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038534+00:00 app[web.1]: at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:567) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038535+00:00 app[web.1]: at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:489) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038535+00:00 app[web.1]: at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:397) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038535+00:00 app[web.1]: at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038536+00:00 app[web.1]: at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038536+00:00 app[web.1]: at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.038536+00:00 app[web.1]: at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
2022-11-22T14:25:37.038537+00:00 app[web.1]:
2022-11-22T14:25:37.092716+00:00 app[web.1]: 2022-11-22 14:25:37.091 ERROR 4 --- [or-http-epoll-1] a.w.r.e.AbstractErrorWebExceptionHandler : [0a942c39-5] 500 Server Error for HTTP GET "/patient-service/patients"
2022-11-22T14:25:37.092717+00:00 app[web.1]:
2022-11-22T14:25:37.092718+00:00 app[web.1]: io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:6115
2022-11-22T14:25:37.092719+00:00 app[web.1]: Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
2022-11-22T14:25:37.092720+00:00 app[web.1]: Error has been observed at the following site(s):
2022-11-22T14:25:37.092720+00:00 app[web.1]: *__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
2022-11-22T14:25:37.092721+00:00 app[web.1]: *__checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
2022-11-22T14:25:37.092722+00:00 app[web.1]: *__checkpoint ⇢ HTTP GET "/patient-service/patients" [ExceptionHandlingWebHandler]
2022-11-22T14:25:37.092722+00:00 app[web.1]: Original Stack Trace:
2022-11-22T14:25:37.092722+00:00 app[web.1]: Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
2022-11-22T14:25:37.092723+00:00 app[web.1]: at io.netty.channel.unix.Errors.newConnectException0(Errors.java:155) ~[netty-transport-native-unix-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092723+00:00 app[web.1]: at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128) ~[netty-transport-native-unix-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092724+00:00 app[web.1]: at io.netty.channel.unix.Socket.finishConnect(Socket.java:359) ~[netty-transport-native-unix-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092725+00:00 app[web.1]: at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092725+00:00 app[web.1]: at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092725+00:00 app[web.1]: at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:567) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092726+00:00 app[web.1]: at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:489) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092726+00:00 app[web.1]: at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:397) ~[netty-transport-classes-epoll-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092726+00:00 app[web.1]: at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092727+00:00 app[web.1]: at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092727+00:00 app[web.1]: at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.84.Final.jar!/:4.1.84.Final]
2022-11-22T14:25:37.092727+00:00 app[web.1]: at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
2022-11-22T14:25:37.092728+00:00 app[web.1]:
2022-11-22T14:25:37.095360+00:00 heroku[router]: at=info method=GET path="/patient-service/patients" host=headmed-gateway.herokuapp.com request_id=6657476d-7856-4a93-8243-5f5fb56b2921 fwd="92.158.60.103" dyno=web.1 connect=0ms service=14ms status=500 bytes=411 protocol=https
this is my application prop for my and micro service
application-heroku.yml (EUREKA SERVER)
server:
port: ${PORT:8761}
spring:
application:
name: eureka-server
cloud:
service-registry:
auto-registration:
enabled: false
eureka:
client:
register-with-eureka: false
fetch-registry: false
management:
endpoints:
web:
exposure:
include: "*"
application-heroku.yml (GATEWAY)
server:
port: ${PORT:8082}
forward-headers-strategy: framework
spring:
application:
name: api-gateway
cloud:
discovery:
enabled: true
gateway:
globalcors:
add-to-simple-url-handler-mapping: true
metrics:
enabled: true
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: patient-service
uri: lb://patient-service
predicates:
- Path=/patients/**
filters:
- RewritePath=/patients(?<segment>/?.*), $\{segment}
eureka:
client:
service-url:
defaultZone: https://headmed-eureka.herokuapp.com/eureka/
instance:
hostname: localhost
nonSecurePort: 80
application-heroku.yml (MICROSERVICE)
server:
port: ${PORT:8080}
forward-headers-strategy: none
eureka:
client:
enabled: true
service-url:
defaultZone: https://headmed-eureka.herokuapp.com/eureka/
instance:
hostname: localhost
instance-id: ${spring.application.name}:${random.uuid}
spring:
application:
name: patient-service
datasource:
url: jdbc:h2:mem:patient;
username: sa
password: password
driverClassName: org.h2.Driver
jpa:
database-platform: org.hibernate.dialect.H2Dialect
show-sql: true
defer-datasource-initialization: true
hibernate:
ddl-auto: create-drop
generate-ddl: true
database: h2
sql:
init:
mode: always
h2:
console:
enabled: true
path: /h2
data:
jpa:
repositories:
bootstrap-mode: default
springdoc:
swagger-ui:
path: /swagger-ui
I think the issue is located on Heroku but i have no idea for a workaround.
I checked to using the nonSecurePort but it's not working.

I solved the problem by adding.
non-secure-port-enabled: true
secure-port-enabled: false
non-secure-port: 80
secure-port: 443

Related

Spring Eureka Client won't connect server

I am making an application with multiple Eureka servers connecting to one Eureka Server. Currently I have two services. The server runs on port 8761, service one runs on 8081 and service two runs on 8082. My first service does connect successfully to the server, however my second service doesn't connect to the server and doesn't give any error messages in the console.
This is from my second service that won't connect:
spring:
application:
name: stock-service
datasource:
url: jdbc:postgresql://localhost:5433/thuusbezorgd
username: postgres
password: secretpassword
driver-class-name: org.postgresql.Driver
jpa:
database-platform: org.hibernate.dialect.PostgresSQLDialect
show-sql: true
jpa:
generate-ddl: true
defer-datasource-initialization: true
hibernate:
ddl-auto: create-drop
sql:
init:
mode: always
server:
port: 8082
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
#SpringBootApplication
#EnableEurekaClient
public class StockServiceApplication {
public static void main(String[] args) {
SpringApplication.run(StockServiceApplication.class, args);
}
}
This is the application.yml from the working service that does connect:
spring:
application:
name: shopping-cart-service
server:
port: 8081
shopping-cart:
redis:
host: localhost
port: 6379
password: ''
memcached:
host: localhost
port: 11211
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
I am getting 0 error messages in my console from Eureka, this is the output of the first service that isn't connecting to the server:
2022-11-29T20:55:10.956+01:00 INFO 8344 --- [ main] c.j.s.StockServiceApplication : Starting StockServiceApplication using Java 18.0.2 with PID 8344 (D:\school\thuusbezorgd-JaimieVos\stock-service\target\classes started by jaimi in D:\school\thuusbezorgd-JaimieVos\stock-service)
2022-11-29T20:55:10.959+01:00 INFO 8344 --- [ main] c.j.s.StockServiceApplication : No active profile set, falling back to 1 default profile: "default"
2022-11-29T20:55:11.424+01:00 INFO 8344 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-11-29T20:55:11.542+01:00 INFO 8344 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 112 ms. Found 2 JPA repository interfaces.
2022-11-29T20:55:11.907+01:00 INFO 8344 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http)
2022-11-29T20:55:11.920+01:00 INFO 8344 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-11-29T20:55:11.920+01:00 INFO 8344 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-11-29T20:55:12.000+01:00 INFO 8344 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-11-29T20:55:12.000+01:00 INFO 8344 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1004 ms
2022-11-29T20:55:12.105+01:00 INFO 8344 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-11-29T20:55:12.141+01:00 INFO 8344 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.5.Final
2022-11-29T20:55:12.260+01:00 WARN 8344 --- [ main] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
2022-11-29T20:55:12.360+01:00 INFO 8344 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-11-29T20:55:12.478+01:00 INFO 8344 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection#1f172892
2022-11-29T20:55:12.479+01:00 INFO 8344 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-11-29T20:55:12.514+01:00 INFO 8344 --- [ main] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2022-11-29T20:55:13.172+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.173+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : relation "product_ingredient" does not exist, skipping
2022-11-29T20:55:13.174+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.175+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : relation "product_ingredient" does not exist, skipping
2022-11-29T20:55:13.176+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.176+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : table "ingredient" does not exist, skipping
2022-11-29T20:55:13.177+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.178+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : table "product" does not exist, skipping
2022-11-29T20:55:13.179+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: 00000
2022-11-29T20:55:13.179+01:00 WARN 8344 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : table "product_ingredient" does not exist, skipping
2022-11-29T20:55:13.222+01:00 INFO 8344 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-11-29T20:55:13.228+01:00 INFO 8344 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-11-29T20:55:13.445+01:00 WARN 8344 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2022-11-29T20:55:13.818+01:00 INFO 8344 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path ''
2022-11-29T20:55:13.826+01:00 INFO 8344 --- [ main] c.j.s.StockServiceApplication : Started StockServiceApplication in 3.279 seconds (process running for 3.777)
So I am wondering if there is something I am completely missing because I cannot find anything that would cause service 1 not to work but service 2 running absolutely fine. When I visit my first service that doesn't connect to the server from its url itself through localhost:8082 it works fine.
I tried switching the ports but service 1 didn't want to connect with any port.

Docker-compose, spring app + mongoDB on non-default port

I have a problem with connecting to mongodb from my app.
Here is the docker-compose file:
version: "3"
services:
olx-crawler:
container_name: olx-crawler
image: myimage:v1
ports:
- "8099:8099"
depends_on:
- olx-mongo
environment:
SPRING_DATA_MONGODB_HOST: olx-mongo
olx-mongo:
container_name: olx-mongo
image: mongo
ports:
- "27777:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: biafra
MONGO_INITDB_ROOT_PASSWORD: password
And here is my application.yaml:
spring:
data:
mongodb:
host: localhost
port: 27777
username: biafra
password: password
authentication-database: admin
logging:
level:
org.springframework.data.mongodb.core.MongoTemplate: DEBUG
server:
port: 8099
Now i have done a similar project to this (docker-compose -> spring app + mongodb) and it worked correctly, but it was with the default mongo port 27017.
And i know you have to use mongo container name instead of localhost, this is what this:
SPRING_DATA_MONGODB_HOST: olx-mongo
is for it replaces "localhost" in application.yml with olx-mongo, as you can see in app logs:
Exception in monitor thread while connecting to server olx-mongo:27777
Here are some logs:
olx-mongo | 2020-04-15T18:00:15.170+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
olx-mongo | 2020-04-15T18:00:15.174+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
olx-mongo | 2020-04-15T18:00:15.175+0000 I NETWORK [listener] Listening on /tmp/mongodb-27017.sock
olx-mongo | 2020-04-15T18:00:15.175+0000 I NETWORK [listener] Listening on 0.0.0.0
olx-mongo | 2020-04-15T18:00:15.175+0000 I NETWORK [listener] waiting for connections on port 27017
olx-crawler | 2020-04-15 18:00:15.436 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
olx-crawler | 2020-04-15 18:00:15.486 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 45ms. Found 1 MongoDB repository interfaces.
olx-mongo | 2020-04-15T18:00:16.000+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
olx-crawler | 2020-04-15 18:00:16.037 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8099 (http)
olx-crawler | 2020-04-15 18:00:16.050 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
olx-crawler | 2020-04-15 18:00:16.052 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
olx-crawler | 2020-04-15 18:00:16.116 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
olx-crawler | 2020-04-15 18:00:16.117 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1487 ms
olx-crawler | 2020-04-15 18:00:16.468 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[olx-mongo:27777], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize
=500}
olx-crawler | 2020-04-15 18:00:16.469 INFO 1 --- [ main] org.mongodb.driver.cluster : Adding discovered server olx-mongo:27777 to client view of cluster
olx-crawler | 2020-04-15 18:00:16.550 INFO 1 --- [olx-mongo:27777] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server olx-mongo:27777
olx-crawler |
olx-crawler | com.mongodb.MongoSocketOpenException: Exception opening socket
olx-crawler | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at java.base/java.lang.Thread.run(Thread.java:844) [na:na]
olx-crawler | Caused by: java.net.ConnectException: Connection refused (Connection refused)
olx-crawler | at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:na]
olx-crawler | at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:400) ~[na:na]
olx-crawler | at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:243) ~[na:na]
olx-crawler | at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:225) ~[na:na]
olx-crawler | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:402) ~[na:na]
olx-crawler | at java.base/java.net.Socket.connect(Socket.java:591) ~[na:na]
olx-crawler | at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | ... 3 common frames omitted
olx-crawler |
olx-crawler | 2020-04-15 18:00:17.096 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
olx-crawler | 2020-04-15 18:00:17.229 INFO 1 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
olx-crawler | 2020-04-15 18:00:17.306 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8099 (http) with context path ''
olx-crawler | 2020-04-15 18:00:17.315 INFO 1 --- [ main] c.e.olxcrawler.OlxCrawlerApplication : Started OlxCrawlerApplication in 3.944 seconds (JVM running for 4.977)
Any help?
Well you wrote
And i know you have to use mongo container name instead of localhost, but it still does not work.
but you have
spring:
data:
mongodb:
host: localhost
port: 27777
Problem is that with this config you are not able to connect to mongo from within spring boot container. It's just configuration for "outside world" of container. For example you can connect to it from your locally running spring boot application which doesn't run inside docker.
To connect to mongo from within dockerized spring boot app, change host to olx-mongo and port to 27017.

spring cloud gateway exception Illegal character in authority at index error

I'm trying to setup spring cloud gateway for a api, but seeing an illegal argument exception with the route uri. Any help is appreciated.
Running this app on Ubuntu and I got the same exception with both Spring boot 2.1.4 and 2.1.5.
This is how configured my application.properties file in the gateway app.
eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka
spring.application.name= api-gateway
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true
spring.cloud.gateway.routes[0].id=reporting-service
spring.cloud.gateway.routes[0].uri = lb://reporting-service
spring.cloud.gateway.routes[0].predicates[0]=Path=/api/reporting/**
This is the exception that I see.
2019-06-06 09:56:17.304 WARN 4561 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initializ ation - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Illegal character in authority at in dex 5: lb://REPORTING-SERVICE
2019-06-06 09:56:17.316 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2019-06-06 09:56:20.317 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : Unregistering ...
2019-06-06 09:56:20.324 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : DiscoveryClient_API-GATEWAY/apitest.****.*****.com:api-gateway:8080 - deregister status: 200
2019-06-06 09:56:20.342 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2019-06-06 09:56:20.353 INFO 4561 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-06 09:56:20.365 ERROR 4561 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Ex ceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Illegal character in authority at index 5: lb://REPORTING-SERVICE
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.1.6.RELEAS E.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.1.6.RELE ASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context -5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.1.6.REL EASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.1.6.RELE ASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:893) ~[spring-context-5.1. 6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.finishRefresh(ReactiveWebServerApplicationContext.jav a:121) ~[spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.6.RELE ASE.jar!/:5.1.6.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:67) ~[spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
Fix the property:
spring.cloud.gateway.routes[0].predicates=Path=/api/reporting/**
spring.cloud.gateway.routes[0].uri=lb://reporting-service
Reference : issue-56480485

Spring Cloud Gateway in Docker Compose returns ERR_NAME_NOT_RESOLVED

I'm building a microservices app and I've run into problem with configuring the Spring Cloud gateway to proxy the calls to the API from frontend running on Nginx server.
When I make a POST request to /users/login, I get this response: OPTIONS http://28a41511677e:8082/login net::ERR_NAME_NOT_RESOLVED.
The string 28a41511677e is the services docker container ID. When I call another service (using GET method), it returns data just fine.
I'm using Eureka discovery server which seems to find all the services correctly. The service in question is registered as 28a41511677e:users-service:8082
Docker compose:
version: "3.7"
services:
db:
build: db/
expose:
- 5432
registry:
build: registryservice/
expose:
- 8761
ports:
- 8761:8761
gateway:
build: gatewayservice/
expose:
- 8080
depends_on:
- registry
users:
build: usersservice/
expose:
- 8082
depends_on:
- registry
- db
timetable:
build: timetableservice/
expose:
- 8081
depends_on:
- registry
- db
ui:
build: frontend/
expose:
- 80
ports:
- 80:80
depends_on:
- gateway
Gateway implementation:
#EnableDiscoveryClient
#SpringBootApplication
public class GatewayserviceApplication {
#Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder){
return builder.routes()
.route("users-service", p -> p.path("/user/**")
.uri("lb://users-service"))
.route("timetable-service", p -> p.path("/routes/**")
.uri("lb://timetable-service"))
.build();
}
public static void main(String[] args) {
SpringApplication.run(GatewayserviceApplication.class, args);
}
}
Gateway settings:
spring:
application:
name: gateway-service
cloud:
gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedMethods:
- GET
- POST
- PUT
- DELETE
eureka:
client:
service-url:
defaultZone: http://registry:8761/eureka
Users service controller:
#RestController
#CrossOrigin
#RequestMapping("/user")
public class UserController {
private UserService userService;
#Autowired
public UserController(UserService userService) {
this.userService = userService;
}
#PostMapping(path = "/login")
ResponseEntity<Long> login(#RequestBody LoginDto loginDto) {
logger.info("Logging in user");
Long uid = userService.logIn(loginDto);
return new ResponseEntity<>(uid, HttpStatus.OK);
}
}
Edit:
This also happens on NPM dev server. I tried changing the lb://users-service to http://users:8082, with no success, still getting ERR_NAME_NOT_RESOLVED.
I however found that when I call the endpoint, the following output can be seen in log:
gateway_1 | 2019-05-19 23:55:10.842 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false
gateway_1 | 2019-05-19 23:55:10.866 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
gateway_1 | 2019-05-19 23:55:10.867 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
gateway_1 | 2019-05-19 23:55:10.868 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false
gateway_1 | 2019-05-19 23:55:10.868 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
gateway_1 | 2019-05-19 23:55:10.869 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: false
gateway_1 | 2019-05-19 23:55:10.871 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
gateway_1 | 2019-05-19 23:55:11.762 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 200
users_1 | 2019-05-19 21:55:19.268 INFO 1 --- [nio-8082-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
users_1 | 2019-05-19 21:55:19.273 INFO 1 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
users_1 | 2019-05-19 21:55:19.513 INFO 1 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 239 ms
users_1 | 2019-05-19 21:55:20.563 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false
users_1 | 2019-05-19 21:55:20.565 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
users_1 | 2019-05-19 21:55:20.565 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
users_1 | 2019-05-19 21:55:20.566 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false
users_1 | 2019-05-19 21:55:20.566 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
users_1 | 2019-05-19 21:55:20.566 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: false
users_1 | 2019-05-19 21:55:20.567 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
users_1 | 2019-05-19 21:55:20.958 INFO 1 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 200
Edit 2:
I enabled logging for the gateway service and this is the output whenever I call /user/login. According to the logs, the gateway matches the /users/login/ correctly, but then starts using just /login for some reason.
2019-05-20 12:58:47.002 DEBUG 1 --- [or-http-epoll-2] r.n.http.server.HttpServerOperations : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] New http connection, requesting read
2019-05-20 12:58:47.025 DEBUG 1 --- [or-http-epoll-2] reactor.netty.channel.BootstrapHandlers : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] Initialized pipeline DefaultChannelPipeline{(BootstrapHandlers$BootstrapInitializerHandler#0 = reactor.netty.channel.BootstrapHandlers$BootstrapInitializerHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpServerCodec), (reactor.left.httpTrafficHandler = reactor.netty.http.server.HttpTrafficHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-05-20 12:58:47.213 DEBUG 1 --- [or-http-epoll-2] r.n.http.server.HttpServerOperations : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] Increasing pending responses, now 1
2019-05-20 12:58:47.242 DEBUG 1 --- [or-http-epoll-2] reactor.netty.http.server.HttpServer : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter#575e590e
2019-05-20 12:58:47.379 TRACE 1 --- [or-http-epoll-2] o.s.c.g.f.WeightCalculatorWebFilter : Weights attr: {}
2019-05-20 12:58:47.817 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.r.RouteDefinitionRouteLocator : RouteDefinition CompositeDiscoveryClient_USERS-SERVICE applying {pattern=/USERS-SERVICE/**} to Path
2019-05-20 12:58:47.952 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.r.RouteDefinitionRouteLocator : RouteDefinition CompositeDiscoveryClient_USERS-SERVICE applying filter {regexp=/USERS-SERVICE/(?<remaining>.*), replacement=/${remaining}} to RewritePath
2019-05-20 12:58:47.960 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.r.RouteDefinitionRouteLocator : RouteDefinition matched: CompositeDiscoveryClient_USERS-SERVICE
2019-05-20 12:58:47.961 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.r.RouteDefinitionRouteLocator : RouteDefinition CompositeDiscoveryClient_GATEWAY-SERVICE applying {pattern=/GATEWAY-SERVICE/**} to Path
2019-05-20 12:58:47.964 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.r.RouteDefinitionRouteLocator : RouteDefinition CompositeDiscoveryClient_GATEWAY-SERVICE applying filter {regexp=/GATEWAY-SERVICE/(?<remaining>.*), replacement=/${remaining}} to RewritePath
2019-05-20 12:58:47.968 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.r.RouteDefinitionRouteLocator : RouteDefinition matched: CompositeDiscoveryClient_GATEWAY-SERVICE
2019-05-20 12:58:47.979 TRACE 1 --- [or-http-epoll-2] o.s.c.g.h.p.RoutePredicateFactory : Pattern "/user/**" matches against value "/user/login"
2019-05-20 12:58:47.980 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.h.RoutePredicateHandlerMapping : Route matched: users-service
2019-05-20 12:58:47.981 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.h.RoutePredicateHandlerMapping : Mapping [Exchange: POST http://gateway:8080/user/login] to Route{id='users-service', uri=lb://users-service, order=0, predicate=org.springframework.cloud.gateway.support.ServerWebExchangeUtils$$Lambda$333/0x000000084035ac40#276b060f, gatewayFilters=[]}
2019-05-20 12:58:47.981 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.h.RoutePredicateHandlerMapping : [ff6d8305] Mapped to org.springframework.cloud.gateway.handler.FilteringWebHandler#4faea64b
2019-05-20 12:58:47.994 DEBUG 1 --- [or-http-epoll-2] o.s.c.g.handler.FilteringWebHandler : Sorted gatewayFilterFactories: [OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter#773f7880}, order=-2147482648}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyWriteResponseFilter#65a4798f}, order=-1}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardPathFilter#4c51bb7}, order=0}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter#878452d}, order=10000}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.LoadBalancerClientFilter#4f2613d1}, order=10100}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.WebsocketRoutingFilter#83298d7}, order=2147483646}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyRoutingFilter#6d24ffa1}, order=2147483647}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardRoutingFilter#426b6a74}, order=2147483647}]
2019-05-20 12:58:47.996 TRACE 1 --- [or-http-epoll-2] o.s.c.g.filter.RouteToRequestUrlFilter : RouteToRequestUrlFilter start
2019-05-20 12:58:47.999 TRACE 1 --- [or-http-epoll-2] o.s.c.g.filter.LoadBalancerClientFilter : LoadBalancerClientFilter url before: lb://users-service/user/login
2019-05-20 12:58:48.432 INFO 1 --- [or-http-epoll-2] c.netflix.config.ChainedDynamicProperty : Flipping property: users-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-05-20 12:58:48.492 INFO 1 --- [or-http-epoll-2] c.n.u.concurrent.ShutdownEnabledTimer : Shutdown hook installed for: NFLoadBalancer-PingTimer-users-service
2019-05-20 12:58:48.496 INFO 1 --- [or-http-epoll-2] c.netflix.loadbalancer.BaseLoadBalancer : Client: users-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=users-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2019-05-20 12:58:48.506 INFO 1 --- [or-http-epoll-2] c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
2019-05-20 12:58:48.543 INFO 1 --- [or-http-epoll-2] c.netflix.config.ChainedDynamicProperty : Flipping property: users-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-05-20 12:58:48.555 INFO 1 --- [or-http-epoll-2] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client users-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=users-service,current list of Servers=[157e1f567371:8082],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
},Server stats: [[Server:157e1f567371:8082; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 01:00:00 CET 1970; First connection made: Thu Jan 01 01:00:00 CET 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList#3cd9b0bf
2019-05-20 12:58:48.580 TRACE 1 --- [or-http-epoll-2] o.s.c.g.filter.LoadBalancerClientFilter : LoadBalancerClientFilter url chosen: http://157e1f567371:8082/user/login
2019-05-20 12:58:48.632 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : Creating new client pool [proxy] for 157e1f567371:8082
2019-05-20 12:58:48.646 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439] Created new pooled channel, now 0 active connections and 1 inactive connections
2019-05-20 12:58:48.651 DEBUG 1 --- [or-http-epoll-2] reactor.netty.channel.BootstrapHandlers : [id: 0xa9634439] Initialized pipeline DefaultChannelPipeline{(BootstrapHandlers$BootstrapInitializerHandler#0 = reactor.netty.channel.BootstrapHandlers$BootstrapInitializerHandler), (SimpleChannelPool$1#0 = io.netty.channel.pool.SimpleChannelPool$1), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-05-20 12:58:48.673 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] onStateChange(PooledConnection{channel=[id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082]}, [connected])
2019-05-20 12:58:48.679 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] onStateChange(GET{uri=/, connection=PooledConnection{channel=[id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082]}}, [configured])
2019-05-20 12:58:48.682 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Registering pool release on close event for channel
2019-05-20 12:58:48.690 DEBUG 1 --- [or-http-epoll-2] r.netty.http.client.HttpClientConnect : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Handler is being applied: {uri=http://157e1f567371:8082/user/login, method=POST}
2019-05-20 12:58:48.701 DEBUG 1 --- [or-http-epoll-2] r.n.channel.ChannelOperationsHandler : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] New sending options
2019-05-20 12:58:48.720 DEBUG 1 --- [or-http-epoll-2] r.n.channel.ChannelOperationsHandler : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Writing object DefaultHttpRequest(decodeResult: success, version: HTTP/1.1)
POST /user/login HTTP/1.1
content-length: 37
accept-language: cs-CZ,cs;q=0.9,en;q=0.8
referer: http://localhost/user/login
cookie: JSESSIONID=6797219EB79F6026BD8F19E9C46C09DB
accept: application/json, text/plain, */*
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
content-type: application/json;charset=UTF-8
origin: http://gateway:8080
accept-encoding: gzip, deflate, br
Forwarded: proto=http;host="gateway:8080";for="172.19.0.7:42958"
X-Forwarded-For: 172.19.0.1,172.19.0.7
X-Forwarded-Proto: http,http
X-Forwarded-Port: 80,8080
X-Forwarded-Host: localhost,gateway:8080
host: 157e1f567371:8082
2019-05-20 12:58:48.751 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Channel connected, now 1 active connections and 0 inactive connections
2019-05-20 12:58:48.759 DEBUG 1 --- [or-http-epoll-2] r.n.channel.ChannelOperationsHandler : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Writing object
2019-05-20 12:58:48.762 DEBUG 1 --- [or-http-epoll-2] reactor.netty.channel.FluxReceive : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] Subscribing inbound receiver [pending: 1, cancelled:false, inboundDone: true]
2019-05-20 12:58:48.808 DEBUG 1 --- [or-http-epoll-2] r.n.channel.ChannelOperationsHandler : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Writing object EmptyLastHttpContent
2019-05-20 12:58:48.809 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] onStateChange(POST{uri=/user/login, connection=PooledConnection{channel=[id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082]}}, [request_sent])
2019-05-20 12:58:49.509 INFO 1 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: users-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-05-20 12:58:49.579 DEBUG 1 --- [or-http-epoll-2] r.n.http.client.HttpClientOperations : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Received response (auto-read:false) : [Set-Cookie=JSESSIONID=7C47A99C1F416F910AB554F4617247D6; Path=/; HttpOnly, X-Content-Type-Options=nosniff, X-XSS-Protection=1; mode=block, Cache-Control=no-cache, no-store, max-age=0, must-revalidate, Pragma=no-cache, Expires=0, X-Frame-Options=DENY, Location=http://157e1f567371:8082/login, Content-Length=0, Date=Mon, 20 May 2019 10:58:49 GMT]
2019-05-20 12:58:49.579 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] onStateChange(POST{uri=/user/login, connection=PooledConnection{channel=[id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082]}}, [response_received])
2019-05-20 12:58:49.581 TRACE 1 --- [or-http-epoll-2] o.s.c.g.filter.NettyWriteResponseFilter : NettyWriteResponseFilter start
2019-05-20 12:58:49.586 DEBUG 1 --- [or-http-epoll-2] reactor.netty.channel.FluxReceive : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Subscribing inbound receiver [pending: 0, cancelled:false, inboundDone: false]
2019-05-20 12:58:49.586 DEBUG 1 --- [or-http-epoll-2] r.n.http.client.HttpClientOperations : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Received last HTTP packet
2019-05-20 12:58:49.593 DEBUG 1 --- [or-http-epoll-2] r.n.channel.ChannelOperationsHandler : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] Writing object DefaultFullHttpResponse(decodeResult: success, version: HTTP/1.1, content: EmptyByteBufBE)
HTTP/1.1 302 Found
Set-Cookie: JSESSIONID=7C47A99C1F416F910AB554F4617247D6; Path=/; HttpOnly
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Location: http://157e1f567371:8082/login
Date: Mon, 20 May 2019 10:58:49 GMT
content-length: 0
2019-05-20 12:58:49.595 DEBUG 1 --- [or-http-epoll-2] r.n.http.server.HttpServerOperations : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] Detected non persistent http connection, preparing to close
2019-05-20 12:58:49.595 DEBUG 1 --- [or-http-epoll-2] r.n.http.server.HttpServerOperations : [id: 0xff6d8305, L:/172.19.0.4:8080 - R:/172.19.0.7:42958] Last Http packet was sent, terminating channel
2019-05-20 12:58:49.598 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] onStateChange(POST{uri=/user/login, connection=PooledConnection{channel=[id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082]}}, [disconnecting])
2019-05-20 12:58:49.598 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Releasing channel
2019-05-20 12:58:49.598 DEBUG 1 --- [or-http-epoll-2] r.n.resources.PooledConnectionProvider : [id: 0xa9634439, L:/172.19.0.4:59624 - R:157e1f567371/172.19.0.5:8082] Channel cleaned, now 0 active connections and 1 inactive connections
I managed to fix it. The problem was actually not in the gateway, it was in the users service. It had improper security configuration and required a login when accessing its endpoints. So, when I called any endpoint, it got redirected to /login.
I added the following code to the service and it works properly now.
#Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
#Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.authorizeRequests().antMatchers("/").permitAll();
httpSecurity.cors().and().csrf().disable();
}
#Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("*"));
configuration.setAllowedHeaders(Arrays.asList("*"));
configuration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
}
That's probably not a proper solution, but on a non production code it gets the job done.

Hazelcast cluster not available on Eureka

I had a problem configuring simple Hazelcast cluster for existing Eureka client.
My application is simple Java SpringBoot application with Eureka discovery enabled, it is properly available for Eureka, however Hazelcast cluster is not.
This is my configuration:
hazelcast.xml
<hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config http://www.hazelcast.com/schema/config/hazelcast-config-3.9.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<properties>
<property name="hazelcast.discovery.enabled">true</property>
<property name="hazelcast.jmx">true</property>
<property name="hazelcast.http.healthcheck.enabled">true</property>
<property name="hazelcast.rest.enabled">true</property>
<property name="hazelcast.logging.type">slf4j</property>
<property name="hazelcast.diagnostics.enabled">true</property>
<property name="hazelcast.diagnostics.metric.level">info</property>
<property name="hazelcast.name">hazelcast-cluster</property>
</properties>
<group>
<name>xxxx</name>
<password>xx</password>
</group>
<instance-name>hazelcast-cluster</instance-name>
<network>
<join>
<multicast enabled="false"/>
<tcp-ip enabled="false"/>
<aws enabled="false"/>
<discovery-strategies>
<discovery-strategy class="com.hazelcast.eureka.one.EurekaOneDiscoveryStrategy" enabled="true">
<properties>
<property name="self-registration">true</property>
<property name="namespace">hazelcast</property>
</properties>
</discovery-strategy>
</discovery-strategies>
</join>
</network>
maps....
</hazelcast>
Spring boot application:
#SpringBootApplication
#EnableAutoConfiguration ( exclude = { WebMvcAutoConfiguration.class } )
#EnableDiscoveryClient
#EnableEurekaClient
public class HazelcastClusterApplication {
public static void main( String[] args ) {
SpringApplication.run( HazelcastClusterApplication.class, args );
}
}
Configuration class:
#Configuration
public class HazelcastInstanceConfiguration {
#Bean
public HazelcastInstance hazelcastInstance(Config config, EurekaClient eurekaClient) {
EurekaOneDiscoveryStrategyFactory.setEurekaClient( eurekaClient );
return Hazelcast.newHazelcastInstance(config);
}
#Bean
public Config config() {
Config config = new ClasspathXmlConfig( "hazelcast.xml" );
return config;
}
}
bootstrap.yml
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8011/eureka/
register-with-eureka: true
spring:
mvc:
favicon:
enabled: false
application:
name: cache-server
cloud:
config:
discovery:
enabled: true
serviceId: config-server
failFast: false
retry:
initialInterval: 10000
maxInterval: 60000
maxAttempts: 12
multiplier: 10.1
config:
name: application.*, ${spring.application.name}*.*
server:
port: 7990
Maven dependencies:
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-eureka-one</artifactId>
<version>1.0.2</version>
</dependency>
After running, 'cache-server' application is available on Eureka, however I guess also 'hazelcast-cluster' should be available, but it is not. Or my assumption is wrong?
Startup logs:
INFO 17628 --- [ main] c.h.s.d.integration.DiscoveryService : [10.230.115.128]:5701 [xxxx] [3.11] Waiting for registration with Eureka...
INFO 17628 --- [ main] c.h.s.d.integration.DiscoveryService : [10.230.115.128]:5701 [xxxx] [3.11] Waiting for registration with Eureka...
INFO 17628 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CACHE-SERVER/pc_data:cache-server:7990: registering service...
INFO 17628 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CACHE-SERVER/pc_data:cache-server:7990 - registration status: 204
INFO 17628 --- [ main] c.h.s.d.integration.DiscoveryService : [10.230.115.128]:5701 [xxxx] [3.11] Waiting for registration with Eureka...
DEBUG 17628 --- [ main] c.h.i.cluster.impl.DiscoveryJoiner : [10.230.115.128]:5701 [xxxx] [3.11] This node will assume master role since no possible member where connected to.
DEBUG 17628 --- [ main] c.h.internal.cluster.ClusterService : [10.230.115.128]:5701 [xxxx] [3.11] Setting master address to [10.230.115.128]:5701
DEBUG 17628 --- [ main] c.h.i.cluster.impl.MembershipManager : [10.230.115.128]:5701 [xxxx] [3.11] Local member list join version is set to 1
DEBUG 17628 --- [ main] c.h.i.cluster.impl.DiscoveryJoiner : [10.230.115.128]:5701 [xxxx] [3.11] PostJoin master: [10.230.115.128]:5701, isMaster: true
INFO 17628 --- [ main] c.h.internal.cluster.ClusterService : [10.230.115.128]:5701 [xxxx] [3.11]
Members {size:1, ver:1} [
Member [10.230.115.128]:5701 - f6ed031e-5740-4daa-b583-5b91d98816c2 this
]
And then my cache-server application is available on Eureka, but not hazelcast-cluster as I guess it should.
Hazelcast client service logs (cutted):
2018-12-11 09:48:01.673 INFO [security-service,,,] 21496 --- [ main] com.hazelcast.client.HazelcastClient : hz.client_0 [xxxx] [3.11] A non-empty group password is configured for the Hazelcast client. Starting with Hazelcast version 3.11, clients with the same group name, but with different group passwords (that do not use authentication) will be accepted to a cluster. The group password configuration will be removed completely in a future release.
2018-12-11 09:48:01.700 INFO [security-service,,,] 21496 --- [ main] com.hazelcast.core.LifecycleService : hz.client_0 [xxxx] [3.11] HazelcastClient 3.11 (20181023 - 1500bbb) is STARTING
2018-12-11 09:48:03.233 INFO [security-service,,,] 21496 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2018-12-11 09:48:03.249 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2018-12-11 09:48:03.264 INFO [security-service,,,] 21496 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-12-11 09:48:03.266 INFO [security-service,,,] 21496 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-12-11 09:48:03.267 INFO [security-service,,,] 21496 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-12-11 09:48:03.267 INFO [security-service,,,] 21496 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-12-11 09:48:03.417 INFO [security-service,,,] 21496 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2018-12-11 09:48:03.421 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2018-12-11 09:48:03.421 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2018-12-11 09:48:03.422 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2018-12-11 09:48:03.422 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2018-12-11 09:48:03.423 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2018-12-11 09:48:03.424 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2018-12-11 09:48:03.424 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2018-12-11 09:48:03.426 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2018-12-11 09:48:03.426 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 5
2018-12-11 09:48:03.426 INFO [security-service,,,] 21496 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-12-11 09:48:03.442 INFO [security-service,,,] 21496 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1544518083442 with initial instances count: 3
2018-12-11 09:48:03.488 INFO [security-service,,,] 21496 --- [ main] c.h.s.d.integration.DiscoveryService : hz.client_0 [xxxx] [3.11] Waiting for registration with Eureka...
2018-12-11 09:48:08.468 INFO [security-service,,,] 21496 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SECURITY-SERVICE/GPLPLW2002.gft.com:security-service:8035 - Re-registering apps/SECURITY-SERVICE
2018-12-11 09:48:08.468 INFO [security-service,,,] 21496 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SECURITY-SERVICE/GPLPLW2002.gft.com:security-service:8035: registering service...
2018-12-11 09:48:08.499 INFO [security-service,,,] 21496 --- [ main] c.h.s.d.integration.DiscoveryService : hz.client_0 [xxxx] [3.11] Waiting for registration with Eureka...
2018-12-11 09:48:08.530 INFO [security-service,,,] 21496 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SECURITY-SERVICE/GPLPLW2002.gft.com:security-service:8035 - registration status: 204
2018-12-11 09:48:13.500 INFO [security-service,,,] 21496 --- [ main] c.h.s.d.integration.DiscoveryService : hz.client_0 [xxxx] [3.11] Waiting for registration with Eureka...
2018-12-11 09:48:18.503 INFO [security-service,,,] 21496 --- [ main] c.h.s.d.integration.DiscoveryService : hz.client_0 [xxxx] [3.11] Waiting for registration with Eureka...
2018-12-11 09:48:23.512 INFO [security-service,,,] 21496 --- [ main] c.h.s.d.integration.DiscoveryService : hz.client_0 [xxxx] [3.11] Waiting for registration with Eureka...
2018-12-11 09:48:28.513 INFO [security-service,,,] 21496 --- [ main] c.h.s.d.integration.DiscoveryService : hz.client_0 [xxxx] [3.11] Waiting for registration with Eureka...
2018-12-11 09:48:33.515 INFO [security-service,,,] 21496 --- [ main] c.h.s.d.integration.DiscoveryService : hz.client_0 [xxxx] [3.11] Waiting for registration with Eureka...
2018-12-11 09:48:33.557 INFO [security-service,,,] 21496 --- [ main] c.h.client.spi.ClientInvocationService : hz.client_0 [xxxx] [3.11] Running with 2 response threads
2018-12-11 09:48:33.742 INFO [security-service,,,] 21496 --- [ main] com.hazelcast.core.LifecycleService : hz.client_0 [xxxx] [3.11] HazelcastClient 3.11 (20181023 - 1500bbb) is STARTED
2018-12-11 09:48:33.772 DEBUG [security-service,,,] 21496 --- [ main] c.h.i.networking.nio.NioNetworking : hz.client_0 [xxxx] [3.11] TcpIpConnectionManager configured with Non Blocking IO-threading model: 1 input threads and 1 output threads
2018-12-11 09:48:33.774 DEBUG [security-service,,,] 21496 --- [ main] c.h.i.networking.nio.NioNetworking : hz.client_0 [xxxx] [3.11] IO threads selector mode is SELECT
2018-12-11 09:48:33.818 WARN [security-service,,,] 21496 --- [ient_0.cluster-] c.h.c.c.ClientConnectionManager : hz.client_0 [xxxx] [3.11] Unable to get alive cluster connection, try in 3000 ms later, attempt 1 of 2.
2018-12-11 09:48:36.822 WARN [security-service,,,] 21496 --- [ient_0.cluster-] c.h.c.c.ClientConnectionManager : hz.client_0 [xxxx] [3.11] Unable to get alive cluster connection, attempt 2 of 2.
2018-12-11 09:48:36.824 WARN [security-service,,,] 21496 --- [ient_0.cluster-] c.h.c.c.ClientConnectionManager : hz.client_0 [xxxx] [3.11] Could not connect to cluster, shutting down the client. Unable to connect to any address! The following addresses were tried: []
2018-12-11 09:48:36.828 INFO [security-service,,,] 21496 --- [clientShutdown-] com.hazelcast.core.LifecycleService : hz.client_0 [xxxx] [3.11] HazelcastClient 3.11 (20181023 - 1500bbb) is SHUTTING_DOWN
2018-12-11 09:48:36.839 INFO [security-service,,,] 21496 --- [clientShutdown-] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2018-12-11 09:48:36.843 INFO [security-service,,,] 21496 --- [clientShutdown-] com.netflix.discovery.DiscoveryClient : Unregistering ...
2018-12-11 09:48:36.844 WARN [security-service,,,] 21496 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: o.....org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManager' defined in class path resource
.......
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcastInstance' defined in class path resource [xxxx/hazelcast/HazelcastClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.hazelcast.core.HazelcastInstance]: Factory method 'hazelcastInstance' threw exception; nested exception is java.lang.IllegalStateException: Unable to connect to any address! The following addresses were tried: []
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 150 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.hazelcast.core.HazelcastInstance]: Factory method 'hazelcastInstance' threw exception; nested exception is java.lang.IllegalStateException: Unable to connect to any address! The following addresses were tried: []
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 163 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to connect to any address! The following addresses were tried: []
at com.hazelcast.client.connection.nio.ClusterConnector.connectToClusterInternal(ClusterConnector.java:206)
at com.hazelcast.client.connection.nio.ClusterConnector.access$400(ClusterConnector.java:56)
at com.hazelcast.client.connection.nio.ClusterConnector$2.call(ClusterConnector.java:215)
at com.hazelcast.client.connection.nio.ClusterConnector$2.call(ClusterConnector.java:211)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:64)
at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:80)
What is wrong with my configuration, is this a server problem or client?
Client configuration:
#Bean
#Autowired
public HazelcastInstance hazelcastInstance( EurekaClient eurekaClient, GroupConfig groupConfig ) {
EurekaOneDiscoveryStrategyFactory.setEurekaClient( eurekaClient );
ClientConfig config = new ClientConfig();
config.setGroupConfig( groupConfig );
config.setProperty( "hazelcast.discovery.enabled", "true" );
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig( new EurekaOneDiscoveryStrategyFactory() );
discoveryStrategyConfig.addProperty( "use-classpath-eureka-client-props", "false" );
discoveryStrategyConfig.addProperty( "self-registration", "false" );
DiscoveryConfig discoveryConfig = new DiscoveryConfig();
discoveryConfig.addDiscoveryStrategyConfig( discoveryStrategyConfig );
config.getNetworkConfig().setDiscoveryConfig( discoveryConfig );
return HazelcastClient.newHazelcastClient( config );
}
The problem is that you use the same EurekaClient for you app discovery (port 7990) and your Hazelcast discovery (port 5701). For more information, read the related GH issue.
You can solve it in two ways:
Use the property use-metadata-for-host-and-port as described here
Use separate Eureka Client and ports for your app and Hazelcast
EDIT: The use-metadata-for-host-and-port will be released in hazelcast-eureka:1.0.3 soon. I've also prepared Hazelcast Eureka Code Sample.
Have you seen the example configs in Eureka plugin repo and also the code sample with Eureka? I see there are some differences in the configs with yours. Please check and let me know if you still have problems.

Resources