PrematureCloseException: Connection prematurely closed - spring

im using Web-flux/Reactive and Webclient, running it on tomcat and spring-boot.
Everything works fine. I read a lot about it. The problem seems to be that whenever you use webclient, you have to return or use the response, otherwise it will close the connection and you didn't consume it yet, and you will see a lot of log messages saying that the connection close prematurely, if i had a scenario where a 404 status code is a error i could just use OnStatus and throw an exception, but my scenario is: when the upstream service returns a 404, i have to return manually a mono empty. so i don't use the response from web client request, i just use ClientResponse from .exchange() to check the status and handle it. My initial problem is the log messages, because is just "garbage", you don't want see a lot of it on your log messages. I've read somewhere that if it happens the connection cant be re-used as well, so it sounds really bad, but i don't know... and i just have this message when is not found, if the response is 200 it returns the object and log messages is not printed.
I tried to use
clientResponse.BodyToMono(Void.Class)
but it doesn't work either.
the log messages keeping apearing
#Bean
public WebClient webClient(
#Value("${http.client.connection-timeout-millis}") final int connectionTimeoutMillis,
#Value("${http.client.socket-timeout-millis}") final int socketTimeoutMillis,
#Value("${http.client.wire-tap-enabled}") final boolean wireTapEnabled,
final ObjectMapper objectMapper) {
Consumer<Connection> doOnConnectedConsumer = connection ->
connection
.addHandler(new ReadTimeoutHandler(socketTimeoutMillis, MILLISECONDS))
.addHandler(new WriteTimeoutHandler(connectionTimeoutMillis, MILLISECONDS));
TcpClient tcpClient = TcpClient.newConnection()
.wiretap(wireTapEnabled)
.option(CONNECT_TIMEOUT_MILLIS, connectionTimeoutMillis)
.doOnConnected(doOnConnectedConsumer);
return WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(HttpClient.from(tcpClient).compress(true)))
.exchangeStrategies(customExchangeStrategies(objectMapper))
.build();
}
// ..........
MultiValueMap<String, String> params = getParams(t1, t2);
return webClient.get()
.uri(HttpUtils.buildUrl(serviceUrl, params, name))
.exchange()
.flatMap(this::handleClientResponse)
.onErrorMap(Exception.class, ex -> handleUnexpectedEx(ex, name, params));
}
log entries
2019-07-08 11:56:51.972 WARN [-,,,] 1504 --- [ctor-http-nio-3] reactor.netty.channel.FluxReceive : [id: 0x66c8568c, L:/127.0.0.1:62319 ! R:localhost/127.0.0.1:8990] An exception has been observed post termination
reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response
2019-07-08 11:56:52.013 DEBUG [-,,,] 1504 --- [ctor-http-nio-2] reactor.netty.ReactorNetty : [id: 0xf50bdf8d, L:/127.0.0.1:62324 ! R:localhost/127.0.0.1:8990] Non Removed handler: ReadTimeoutHandler, context: ChannelHandlerContext(ReadTimeoutHandler, [id: 0xf50bdf8d, L:/127.0.0.1:62324 ! R:localhost/127.0.0.1:8990]), pipeline: DefaultChannelPipeline{(reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.left.decompressor = io.netty.handler.codec.http.HttpContentDecompressor), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-07-08 11:56:52.014 DEBUG [-,,,] 1504 --- [ctor-http-nio-2] reactor.netty.ReactorNetty : [id: 0xf50bdf8d, L:/127.0.0.1:62324 ! R:localhost/127.0.0.1:8990] Non Removed handler: WriteTimeoutHandler, context: ChannelHandlerContext(WriteTimeoutHandler, [id: 0xf50bdf8d, L:/127.0.0.1:62324 ! R:localhost/127.0.0.1:8990]), pipeline: DefaultChannelPipeline{(reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.left.decompressor = io.netty.handler.codec.http.HttpContentDecompressor), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-07-08 11:56:52.014 DEBUG [-,,,] 1504 --- [ctor-http-nio-2] r.netty.resources.NewConnectionProvider : [id: 0xf50bdf8d, L:/127.0.0.1:62324 ! R:localhost/127.0.0.1:8990] onStateChange([response_incomplete], GET{uri=/service/TWFDHF?T1=1.0.0&T2=1, connection=SimpleConnection{channel=[id: 0xf50bdf8d, L:/127.0.0.1:62324 ! R:localhost/127.0.0.1:8990]}})
2019-07-08 11:56:52.014 WARN [-,,,] 1504 --- [ctor-http-nio-2] reactor.netty.channel.FluxReceive : [id: 0xf50bdf8d, L:/127.0.0.1:62324 ! R:localhost/127.0.0.1:8990] An exception has been observed post termination
log entries with wiretap enabled
2019-07-10 14:51:19.295 DEBUG [-,,,] 2940 --- [ctor-http-nio-2] reactor.netty.tcp.TcpClient : [id: 0x677da0d4, L:/127.0.0.1:62385 ! R:localhost/127.0.0.1:8990] UNREGISTERED
2019-07-10 14:51:19.541 DEBUG [-,,,] 2940 --- [ctor-http-nio-4] reactor.netty.tcp.TcpClient : [id: 0xa7f41d1e, L:/127.0.0.1:62384 - R:localhost/127.0.0.1:8990] CLOSE
2019-07-10 14:51:19.542 DEBUG [-,,,] 2940 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990] Channel cleaned, now 0 active connections and 9 inactive connections
2019-07-10 14:51:19.542 DEBUG [-,,,] 2940 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990] Channel closed, now 0 active connections and 8 inactive connections
2019-07-10 14:51:19.542 DEBUG [-,,,] 2940 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990] Non Removed handler: ReadTimeoutHandler, context: ChannelHandlerContext(ReadTimeoutHandler, [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990]), pipeline: DefaultChannelPipeline{(reactor.left.loggingHandler = io.netty.handler.logging.LoggingHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-07-10 14:51:19.543 DEBUG [-,,,] 2940 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990] Non Removed handler: WriteTimeoutHandler, context: ChannelHandlerContext(WriteTimeoutHandler, [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990]), pipeline: DefaultChannelPipeline{(reactor.left.loggingHandler = io.netty.handler.logging.LoggingHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-07-10 14:51:19.543 DEBUG [-,,,] 2940 --- [ctor-http-nio-4] reactor.netty.tcp.TcpClient : [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990] INACTIVE
2019-07-10 14:51:19.544 DEBUG [-,,,] 2940 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990] onStateChange(GET{uri=/dataviews/TWN_EMPLBENINFO_FIXED?version=1.0.0&sequence=1, connection=PooledConnection{channel=[id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990]}}, [response_incomplete])
2019-07-10 14:51:19.544 WARN [-,,,] 2940 --- [ctor-http-nio-4] reactor.netty.channel.FluxReceive : [id: 0xa7f41d1e, L:/127.0.0.1:62384 ! R:localhost/127.0.0.1:8990] An exception has been observed post termination
and my handler
protected Mono handleClientResponseError(final ClientResponse clientResponse) {
clientResponse.bodyToMono(Void.class);
Mono<ErrorResponse> errorResponse = clientResponse.body(BodyExtractors.toMono(ErrorResponse.class));
return errorResponse.flatMap(err -> {
log.debug("Received HttpStatusCodeException when calling {} Registry: {}", getGatewayName(),
err.getErrorEnvelope().getMessage());
return Mono.error(new UpStreamServiceHttpException(err, clientResponse.rawStatusCode()));
}).switchIfEmpty(Mono.error(() -> {
log.debug("Received HttpStatusCodeException when calling {} Registry: {}", getGatewayName());
return new UpStreamServiceHttpException("Bad Gateway", clientResponse.rawStatusCode());
}));
}
I tried already use clientResponse.bodyToMono(Void.class); to complete the response, but it still doesnt work, i need a way to finish the response from web-client, and then be able to re-use the connection pool and get rid of those log messages
i've created an issue on github, but it was closed, so im creating this question here. https://github.com/spring-projects/spring-framework/issues/23249

so i finnaly found a way to finish the response and i will share here for anyone who come across this problem
before i had this:
private Mono<Optional<JsonNode>> handleHttpErrorStatus(final ClientResponse clientResponse) {
if (clientResponse.statusCode().equals(HttpStatus.NOT_FOUND)) {
clientResponse.bodyToMono(Void.class);
return Mono.just(Optional.empty());
} else {
return handleClientResponseError(clientResponse);
}
}
But it didn't work, apparently because i wasn't returning it anyway, so after digging i tried this:
private Mono<Optional<JsonNode>> handleHttpErrorStatus(final ClientResponse clientResponse) {
if (clientResponse.statusCode().equals(HttpStatus.NOT_FOUND)) {
return clientResponse.bodyToMono(Void.class).thenReturn((Optional.empty()));
} else {
return handleClientResponseError(clientResponse);
}
}
and it works fine, i checked the wiretap logs and everything looks fine now.
2019-07-10 16:44:39.096 DEBUG [-,,,] 16260 --- [ctor-http-nio-2] r.n.http.client.HttpClientOperations : [id: 0x461d8170, L:/127.0.0.1:64298 - R:localhost/127.0.0.1:8990] Received response (auto-read:false) : [Content-Type=application/json;charset=UTF-8, Transfer-Encoding=chunked, Date=Wed, 10 Jul 2019 15:44:38 GMT]
2019-07-10 16:44:39.096 DEBUG [-,,,] 16260 --- [ctor-http-nio-2] r.n.resources.PooledConnectionProvider : [id: 0x461d8170, L:/127.0.0.1:64298 - R:localhost/127.0.0.1:8990] onStateChange(GET{uri=/dataviews/TWN_EMPLPIM_AVRO?version=1.0.0&sequence=1, connection=PooledConnection{channel=[id: 0x461d8170, L:/127.0.0.1:64298 - R:localhost/127.0.0.1:8990]}}, [response_received])
2019-07-10 16:44:39.098 DEBUG [-,bdd6433efa276f10,bdd6433efa276f10,false] 16260 --- [ctor-http-nio-2] reactor.netty.channel.FluxReceive : [id: 0x461d8170, L:/127.0.0.1:64298 - R:localhost/127.0.0.1:8990] Subscribing inbound receiver [pending: 0, cancelled:false, inboundDone: false]
2019-07-10 16:44:39.099 DEBUG [-,bdd6433efa276f10,bdd6433efa276f10,false] 16260 --- [ctor-http-nio-2] reactor.netty.tcp.TcpClient : [id: 0x461d8170, L:/127.0.0.1:64298 - R:localhost/127.0.0.1:8990] CLOSE
2019-07-10 16:44:39.099 DEBUG [-,bdd6433efa276f10,bdd6433efa276f10,false] 16260 --- [ctor-http-nio-2] r.n.resources.PooledConnectionProvider : [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990] Channel cleaned, now 1 active connections and 1 inactive connections
2019-07-10 16:44:39.099 DEBUG [-,bdd6433efa276f10,bdd6433efa276f10,false] 16260 --- [ctor-http-nio-2] r.n.resources.PooledConnectionProvider : [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990] Channel closed, now 1 active connections and 0 inactive connections
2019-07-10 16:44:39.099 DEBUG [-,bdd6433efa276f10,bdd6433efa276f10,false] 16260 --- [ctor-http-nio-2] reactor.netty.ReactorNetty : [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990] Non Removed handler: ReadTimeoutHandler, context: ChannelHandlerContext(ReadTimeoutHandler, [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990]), pipeline: DefaultChannelPipeline{(reactor.left.loggingHandler = io.netty.handler.logging.LoggingHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-07-10 16:44:39.099 DEBUG [-,bdd6433efa276f10,bdd6433efa276f10,false] 16260 --- [ctor-http-nio-2] reactor.netty.ReactorNetty : [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990] Non Removed handler: WriteTimeoutHandler, context: ChannelHandlerContext(WriteTimeoutHandler, [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990]), pipeline: DefaultChannelPipeline{(reactor.left.loggingHandler = io.netty.handler.logging.LoggingHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-07-10 16:44:39.100 DEBUG [-,,,] 16260 --- [ctor-http-nio-2] reactor.netty.tcp.TcpClient : [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990] READ COMPLETE
2019-07-10 16:44:39.102 DEBUG [-,,,] 16260 --- [ctor-http-nio-2] reactor.netty.tcp.TcpClient : [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990] INACTIVE
2019-07-10 16:44:39.102 DEBUG [-,,,] 16260 --- [ctor-http-nio-2] reactor.netty.tcp.TcpClient : [id: 0x461d8170, L:/127.0.0.1:64298 ! R:localhost/127.0.0.1:8990] UNREGISTERED
2019-07-10 16:44:39.122 DEBUG [-,,,] 16260 --- [ctor-http-nio-2] reactor.netty.tcp.TcpClient : [id: 0xbe2cb147, L:/127.0.0.1:64295 - R:localhost/127.0.0.1:8990] READ: 398B

I had the same issue that I kept battling with for 5 days wondering what exactly I had done wrong after a new feature deployment. I finally had my Eureka moment.
So in my Dockerfile I had exposed the default port 8080.
Which meant the tomcat server in my application image would always be available on that port. My container also had to be running on port 8080 (inside my .yml file)
before I apply the port mapping directive to map the external port 9003 on my linux host to the 8080 in the container.
What I missed was that, during the deployment of the services using the docker-compose file, I forgot to change the server.port in the application.yml file to 8080 so that the port mapping could happen. I left it as 9003 (because I was using 9003 on my local machine to test the app) which meant anytime I started the containers using docker-compose, my service port was mapped as
0.0.0.0:9003 -> 9003/tcp instead of 0.0.0.0:9003 -> 8080/tcp.
This was why the api-gateway kept throwing the
PrematureCloseException: Connection prematurely closed
because there was actually no internal port 9003 found in the container instance of my microservice for the 9003 on the linux host to map to.
I just had to change the 9003 in my application.yml to 8080 and that was all.

I've solved this issue on my Tests with a workaround, by adding following lines in the end of each method:
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}

Related

Trace id propagation in Spring Boot 3 with Spring cloud streams and WebFlux

I tried to use spring cloud stream with kafka binder. But when I called WebClient in chain, then trace id is lost.
My flow is 'external service' -> 'functionStream-in' -> 'http call' -> functionStream-out' -> 'testStream-in' -> 'testStream-out' -> 'external service'
But after http call(or not?) the trace id is not propagated and I don't understand why. If I remove http call, then everything is OK.
I tried to add Hooks.enableAutomaticContextPropagation();, but that didn't help.
I tried to add ContextSnapshot.setThreadLocalsFrom around http call - same thing.
How can I solve it?
Dependencies:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.cloud:spring-cloud-stream'
implementation 'org.springframework.cloud:spring-cloud-starter-stream-kafka'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
implementation "io.projectreactor:reactor-core:3.5.3"
implementation "io.micrometer:context-propagation:1.0.2"
implementation "io.micrometer:micrometer-core:1.10.4"
implementation "io.micrometer:micrometer-tracing:1.0.2"
}
application.yml:
spring:
cloud.stream:
kafka.binder:
enableObservation: true
headers:
- b3
function.definition: functionStream;testStream
default.producer.useNativeEncoding: true
bindings:
functionStream-in-0:
destination: spring-in
group: spring-test1
functionStream-out-0:
destination: test-in
testStream-in-0:
destination: test-in
group: spring-test2
testStream-out-0:
destination: spring-out
integration:
management:
observation-patterns: "*"
kafka:
bootstrap-servers: localhost:9092
consumer:
auto-offset-reset: earliest
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
properties:
spring.deserializer.value.delegate.class: org.apache.kafka.common.serialization.StringDeserializer
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
management:
tracing:
enabled: true
sampling.probability: 1.0
propagation.type: b3
logging.pattern.level: "%5p [%X{traceId:-},%X{spanId:-}]"
Code:
#Bean
WebClient webClient(final WebClient.Builder builder) {
return builder.build();
}
#Bean
Function<Flux<Message<String>>, Flux<Message<String>>> functionStream(final WebClient webClient, final ObservationRegistry registry) {
return flux -> flux
.<Message<String>>handle((msg, sink) -> {
log.info("functionStream-1");
sink.next(msg);
})
.flatMap(msg -> webClient.get()
.uri("http://localhost:8080/test")
.exchangeToMono(httpResponse -> httpResponse.bodyToMono(String.class)
.map(httpBody -> MessageBuilder.withPayload(httpBody)
.copyHeaders(httpResponse.headers().asHttpHeaders())
.build())
.<Message<String>>handle((m, sink) -> {
log.info("functionStream-3");
sink.next(m);
})
)
)
.handle((msg, sink) -> {
log.info("functionStream-2");
sink.next(msg);
});
}
#Bean
Function<Flux<Message<String>>, Flux<Message<String>>> testStream(final ObservationRegistry registry) {
return flux -> flux
.publishOn(Schedulers.boundedElastic())
.<Message<String>>handle((msg, sink) -> {
log.info("testStream-1");
sink.next(msg);
})
.map(msg -> MessageBuilder
.withPayload(msg.getPayload())
.copyHeaders(msg.getHeaders())
.build());
}
#Bean
RouterFunction<ServerResponse> router(final ObservationRegistry registry) {
return route()
.GET("/test", r -> ServerResponse.ok().body(Mono.deferContextual(contextView -> {
try (final var scope = ContextSnapshot.setThreadLocalsFrom(contextView, ObservationThreadLocalAccessor.KEY)) {
log.info("GET /test");
}
return Mono.just("answer");
}), String.class))
.build();
}
With this code I have output:
2023-02-16T17:06:22.111 INFO [63ee385de15f1061dea076eb06b0d1e0,39a60588a695a702] 220348 --- [container-0-C-1] com.example.demo.TestApplication : functionStream-1
2023-02-16T17:06:22.166 WARN [63ee385de15f1061dea076eb06b0d1e0,39a60588a695a702] 220348 --- [container-0-C-1] i.m.o.c.ObservationThreadLocalAccessor : Scope from ObservationThreadLocalAccessor [null] is not the same as the one from ObservationRegistry [io.micrometer.observation.SimpleObservation$SimpleScope#523fe6a9]. You must have created additional scopes and forgotten to close them. Will close both of them
2023-02-16T17:06:22.170 WARN [63ee385de15f1061dea076eb06b0d1e0,de5d233d531b10f7] 220348 --- [container-0-C-1] i.m.o.c.ObservationThreadLocalAccessor : Scope from ObservationThreadLocalAccessor [null] is not the same as the one from ObservationRegistry [io.micrometer.observation.SimpleObservation$SimpleScope#545339d8]. You must have created additional scopes and forgotten to close them. Will close both of them
2023-02-16T17:06:22.187 WARN [63ee385de15f1061dea076eb06b0d1e0,de5d233d531b10f7] 220348 --- [container-0-C-1] i.m.o.c.ObservationThreadLocalAccessor : Scope from ObservationThreadLocalAccessor [null] is not the same as the one from ObservationRegistry [io.micrometer.observation.SimpleObservation$SimpleScope#44400bcc]. You must have created additional scopes and forgotten to close them. Will close both of them
2023-02-16T17:06:22.361 INFO [63ee385de15f1061dea076eb06b0d1e0,908f48f8485a4277] 220348 --- [ctor-http-nio-4] com.example.demo.TestApplication : GET /test
2023-02-16T17:06:22.407 INFO [,] 220348 --- [ctor-http-nio-3] com.example.demo.TestApplication : functionStream-3
2023-02-16T17:06:22.409 INFO [,] 220348 --- [ctor-http-nio-3] com.example.demo.TestApplication : functionStream-2
2023-02-16T17:06:22.448 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,dd1b0fd86a6c39ca] 220348 --- [ctor-http-nio-3] o.a.k.clients.admin.AdminClientConfig : AdminClientConfig values:
2023-02-16T17:06:22.456 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,dd1b0fd86a6c39ca] 220348 --- [ctor-http-nio-3] o.a.kafka.common.utils.AppInfoParser : Kafka version: 3.3.2
2023-02-16T17:06:22.457 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,dd1b0fd86a6c39ca] 220348 --- [ctor-http-nio-3] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: b66af662e61082cb
2023-02-16T17:06:22.457 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,dd1b0fd86a6c39ca] 220348 --- [ctor-http-nio-3] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1676556382456
2023-02-16T17:06:22.477 INFO [,] 220348 --- [| adminclient-6] o.a.kafka.common.utils.AppInfoParser : App info kafka.admin.client for adminclient-6 unregistered
2023-02-16T17:06:22.481 INFO [,] 220348 --- [| adminclient-6] o.apache.kafka.common.metrics.Metrics : Metrics scheduler closed
2023-02-16T17:06:22.481 INFO [,] 220348 --- [| adminclient-6] o.apache.kafka.common.metrics.Metrics : Closing reporter org.apache.kafka.common.metrics.JmxReporter
2023-02-16T17:06:22.481 INFO [,] 220348 --- [| adminclient-6] o.apache.kafka.common.metrics.Metrics : Metrics reporters closed
2023-02-16T17:06:22.512 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,b5babc6bef4e30ca] 220348 --- [oundedElastic-1] com.example.demo.TestApplication : testStream-1
2023-02-16T17:06:22.539 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,30126c50752d5928] 220348 --- [oundedElastic-1] o.a.k.clients.admin.AdminClientConfig : AdminClientConfig values:
2023-02-16T17:06:22.543 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,30126c50752d5928] 220348 --- [oundedElastic-1] o.a.kafka.common.utils.AppInfoParser : Kafka version: 3.3.2
2023-02-16T17:06:22.544 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,30126c50752d5928] 220348 --- [oundedElastic-1] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: b66af662e61082cb
2023-02-16T17:06:22.544 INFO [63ee385eda64dcebdd1b0fd86a6c39ca,30126c50752d5928] 220348 --- [oundedElastic-1] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1676556382543
Without http call I have output:
2023-02-16T17:03:09.518 INFO [63ee379d924e5645fc1d9e27b8135b48,9ad408700a3b5684] 204228 --- [container-0-C-1] com.example.demo.TestApplication : functionStream-1
2023-02-16T17:03:09.518 INFO [63ee379d924e5645fc1d9e27b8135b48,9ad408700a3b5684] 204228 --- [container-0-C-1] com.example.demo.TestApplication : functionStream-2
2023-02-16T17:03:09.615 INFO [63ee379d924e5645fc1d9e27b8135b48,3d4c6bd14a3ca4b6] 204228 --- [container-0-C-1] o.a.k.clients.admin.AdminClientConfig : AdminClientConfig values:
2023-02-16T17:03:09.629 INFO [63ee379d924e5645fc1d9e27b8135b48,3d4c6bd14a3ca4b6] 204228 --- [container-0-C-1] o.a.kafka.common.utils.AppInfoParser : Kafka version: 3.3.2
2023-02-16T17:03:09.629 INFO [63ee379d924e5645fc1d9e27b8135b48,3d4c6bd14a3ca4b6] 204228 --- [container-0-C-1] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: b66af662e61082cb
2023-02-16T17:03:09.629 INFO [63ee379d924e5645fc1d9e27b8135b48,3d4c6bd14a3ca4b6] 204228 --- [container-0-C-1] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1676556189628
2023-02-16T17:03:09.691 INFO [,] 204228 --- [| adminclient-6] o.a.kafka.common.utils.AppInfoParser : App info kafka.admin.client for adminclient-6 unregistered
2023-02-16T17:03:09.693 INFO [,] 204228 --- [| adminclient-6] o.apache.kafka.common.metrics.Metrics : Metrics scheduler closed
2023-02-16T17:03:09.693 INFO [,] 204228 --- [| adminclient-6] o.apache.kafka.common.metrics.Metrics : Closing reporter org.apache.kafka.common.metrics.JmxReporter
2023-02-16T17:03:09.693 INFO [,] 204228 --- [| adminclient-6] o.apache.kafka.common.metrics.Metrics : Metrics reporters closed
2023-02-16T17:03:09.859 INFO [63ee379d924e5645fc1d9e27b8135b48,b92a1a59ffd32d80] 204228 --- [oundedElastic-1] com.example.demo.TestApplication : testStream-1
2023-02-16T17:03:09.868 INFO [63ee379d924e5645fc1d9e27b8135b48,db97f5eed98602f6] 204228 --- [oundedElastic-1] o.a.k.clients.admin.AdminClientConfig : AdminClientConfig values:
2023-02-16T17:03:09.874 INFO [63ee379d924e5645fc1d9e27b8135b48,db97f5eed98602f6] 204228 --- [oundedElastic-1] o.a.kafka.common.utils.AppInfoParser : Kafka version: 3.3.2
2023-02-16T17:03:09.874 INFO [63ee379d924e5645fc1d9e27b8135b48,db97f5eed98602f6] 204228 --- [oundedElastic-1] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: b66af662e61082cb
2023-02-16T17:03:09.874 INFO [63ee379d924e5645fc1d9e27b8135b48,db97f5eed98602f6] 204228 --- [oundedElastic-1] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1676556189874

Spring Boot Kafka Connection Problem for local docker service

I am using docker to initiate kafka and zookeper services on local machine(mac os). Here is my docker-compose.yml file;
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 10.200.10.1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
10.200.10.1 : this is my docker host ip. i find it via this command ;
ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1
I can create topic inside docker container via ;
kafka-topics.sh --bootstrap-server :9092 --create --topic topic1 --partitions 1 --replication-factor 1
and initiate producer by :
kafka-console-consumer.sh --bootstrap-server :9092 --group sam --topic topic1
and initiate consumer by :
kafka-console-producer.sh --broker-list :9092 --topic topic1
There is no problem everything is ok on the terminals; i can send message via producer and receive it on consumer.
But i can not send message via Spring Boot app which I describe it below;
application.yml file;
spring:
kafka:
producer:
bootstrap-servers: 0.0.0.0:9092
KafkaConfiguration;
#Configuration
public class KafkaConfiguration {
#Value("${spring.kafka.producer.bootstrap-servers}")
private String bootstrapAddress;
#Bean
public ProducerFactory<String, String> producerFactory() {
Map<String, Object> configProps = new HashMap<>();
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
return new DefaultKafkaProducerFactory<>(configProps);
}
#Bean
public KafkaTemplate<String, String> kafkaTemplate() {
return new KafkaTemplate<>(producerFactory());
}
}
I am using this sendSms function on my producer;
#Slf4j
#Component
#RequiredArgsConstructor
public class MessageProducer {
private final KafkaTemplate kafkaTemplate;
public void sendSms(String sms) {
kafkaTemplate.send("topic1", sms)
.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {
#Override
public void onSuccess(SendResult<String, String> result) {
log.info("Message '{}' sent to kafka with offset : {}", sms, result.getRecordMetadata().offset());
}
#Override
public void onFailure(Throwable ex) {
log.error("Enable to send to message : {}. ex : {}", sms, ex.getMessage());
}
});
}
}
When i try to send a message, i am getting this error ;
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_201]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_201]
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:216) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:531) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.poll(Selector.java:483) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:539) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244) [kafka-clients-2.3.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
2020-05-17 19:53:06.210 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Node -1 disconnected.
2020-05-17 19:53:06.210 WARN 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Connection to node -1 (/0.0.0.0:9092) could not be established. Broker may not be available.
2020-05-17 19:53:06.210 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Give up sending metadata request since no node is available
2020-05-17 19:53:06.265 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Give up sending metadata request since no node is available
2020-05-17 19:53:06.319 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initialize connection to node 0.0.0.0:9092 (id: -1 rack: null) for sending metadata request
2020-05-17 19:53:06.320 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initiating connection to node 0.0.0.0:9092 (id: -1 rack: null) using address /0.0.0.0
2020-05-17 19:53:06.320 DEBUG 15739 --- [ad | producer-1] o.apache.kafka.common.network.Selector : [Producer clientId=producer-1] Connection with /0.0.0.0 disconnected
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_201]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_201]
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:216) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:531) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.poll(Selector.java:483) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:539) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244) [kafka-clients-2.3.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
here is the whole log output ;
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.7.RELEASE)
2020-05-17 19:52:57.176 INFO 15739 --- [ restartedMain] .p.SpringKafkaProducerExampleApplication : Starting SpringKafkaProducerExampleApplication on sam-MacBook-Pro.local with PID 15739 (/Users/sam/Downloads/kafka-hello/spring-kafka-producer-example/build/classes/java/main started by sam in /Users/sam/Downloads/kafka-hello/spring-kafka-producer-example)
2020-05-17 19:52:57.180 INFO 15739 --- [ restartedMain] .p.SpringKafkaProducerExampleApplication : No active profile set, falling back to default profiles: default
2020-05-17 19:52:57.231 INFO 15739 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-05-17 19:52:57.231 INFO 15739 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-05-17 19:52:58.111 INFO 15739 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2020-05-17 19:52:58.120 INFO 15739 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-17 19:52:58.120 INFO 15739 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.34]
2020-05-17 19:52:58.181 INFO 15739 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-17 19:52:58.181 INFO 15739 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 950 ms
2020-05-17 19:52:58.373 INFO 15739 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-17 19:52:58.562 INFO 15739 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-05-17 19:52:58.610 INFO 15739 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''
2020-05-17 19:52:58.614 INFO 15739 --- [ restartedMain] .p.SpringKafkaProducerExampleApplication : Started SpringKafkaProducerExampleApplication in 1.878 seconds (JVM running for 2.602)
2020-05-17 19:53:04.243 INFO 15739 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-17 19:53:04.243 INFO 15739 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-05-17 19:53:04.248 INFO 15739 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 5 ms
2020-05-17 19:53:06.105 INFO 15739 --- [nio-8081-exec-1] c.s.e.kafka.producer.MessageController : Message request received : sam
2020-05-17 19:53:06.130 INFO 15739 --- [nio-8081-exec-1] o.a.k.clients.producer.ProducerConfig : ProducerConfig values:
acks = 1
batch.size = 16384
bootstrap.servers = [0.0.0.0:9092]
buffer.memory = 33554432
client.dns.lookup = default
client.id =
compression.type = none
connections.max.idle.ms = 540000
delivery.timeout.ms = 120000
enable.idempotence = false
interceptor.classes = []
key.serializer = class org.apache.kafka.common.serialization.StringSerializer
linger.ms = 0
max.block.ms = 60000
max.in.flight.requests.per.connection = 5
max.request.size = 1048576
metadata.max.age.ms = 300000
metric.reporters = []
metrics.num.samples = 2
metrics.recording.level = INFO
metrics.sample.window.ms = 30000
partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
receive.buffer.bytes = 32768
reconnect.backoff.max.ms = 1000
reconnect.backoff.ms = 50
request.timeout.ms = 30000
retries = 2147483647
retry.backoff.ms = 100
sasl.client.callback.handler.class = null
sasl.jaas.config = null
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.min.time.before.relogin = 60000
sasl.kerberos.service.name = null
sasl.kerberos.ticket.renew.jitter = 0.05
sasl.kerberos.ticket.renew.window.factor = 0.8
sasl.login.callback.handler.class = null
sasl.login.class = null
sasl.login.refresh.buffer.seconds = 300
sasl.login.refresh.min.period.seconds = 60
sasl.login.refresh.window.factor = 0.8
sasl.login.refresh.window.jitter = 0.05
sasl.mechanism = GSSAPI
security.protocol = PLAINTEXT
send.buffer.bytes = 131072
ssl.cipher.suites = null
ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
ssl.endpoint.identification.algorithm = https
ssl.key.password = null
ssl.keymanager.algorithm = SunX509
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.protocol = TLS
ssl.provider = null
ssl.secure.random.implementation = null
ssl.trustmanager.algorithm = PKIX
ssl.truststore.location = null
ssl.truststore.password = null
ssl.truststore.type = JKS
transaction.timeout.ms = 60000
transactional.id = null
value.serializer = class org.apache.kafka.common.serialization.StringSerializer
2020-05-17 19:53:06.143 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name bufferpool-wait-time
2020-05-17 19:53:06.148 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name buffer-exhausted-records
2020-05-17 19:53:06.153 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name errors
2020-05-17 19:53:06.158 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name produce-throttle-time
2020-05-17 19:53:06.163 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name connections-closed:
2020-05-17 19:53:06.164 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name connections-created:
2020-05-17 19:53:06.164 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name successful-authentication:
2020-05-17 19:53:06.164 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name successful-reauthentication:
2020-05-17 19:53:06.164 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name successful-authentication-no-reauth:
2020-05-17 19:53:06.165 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name failed-authentication:
2020-05-17 19:53:06.165 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name failed-reauthentication:
2020-05-17 19:53:06.165 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name reauthentication-latency:
2020-05-17 19:53:06.165 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name bytes-sent-received:
2020-05-17 19:53:06.166 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name bytes-sent:
2020-05-17 19:53:06.166 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name bytes-received:
2020-05-17 19:53:06.167 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name select-time:
2020-05-17 19:53:06.167 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name io-time:
2020-05-17 19:53:06.170 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name batch-size
2020-05-17 19:53:06.171 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name compression-rate
2020-05-17 19:53:06.171 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name queue-time
2020-05-17 19:53:06.171 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name request-time
2020-05-17 19:53:06.172 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name records-per-request
2020-05-17 19:53:06.172 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name record-retries
2020-05-17 19:53:06.172 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name record-size
2020-05-17 19:53:06.173 DEBUG 15739 --- [nio-8081-exec-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name batch-split-rate
2020-05-17 19:53:06.174 DEBUG 15739 --- [ad | producer-1] o.a.k.clients.producer.internals.Sender : [Producer clientId=producer-1] Starting Kafka producer I/O thread.
2020-05-17 19:53:06.176 INFO 15739 --- [nio-8081-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka version: 2.3.1
2020-05-17 19:53:06.177 INFO 15739 --- [nio-8081-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: 18a913733fb71c01
2020-05-17 19:53:06.177 INFO 15739 --- [nio-8081-exec-1] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1589741586174
2020-05-17 19:53:06.178 DEBUG 15739 --- [nio-8081-exec-1] o.a.k.clients.producer.KafkaProducer : [Producer clientId=producer-1] Kafka producer started
2020-05-17 19:53:06.179 DEBUG 15739 --- [nio-8081-exec-1] o.s.k.core.DefaultKafkaProducerFactory : Created new Producer: CloseSafeProducer [delegate=org.apache.kafka.clients.producer.KafkaProducer#4f619fb3]
2020-05-17 19:53:06.185 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initialize connection to node 0.0.0.0:9092 (id: -1 rack: null) for sending metadata request
2020-05-17 19:53:06.187 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initiating connection to node 0.0.0.0:9092 (id: -1 rack: null) using address /0.0.0.0
2020-05-17 19:53:06.194 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name node--1.bytes-sent
2020-05-17 19:53:06.195 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name node--1.bytes-received
2020-05-17 19:53:06.195 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.common.metrics.Metrics : Added sensor with name node--1.latency
2020-05-17 19:53:06.208 DEBUG 15739 --- [ad | producer-1] o.apache.kafka.common.network.Selector : [Producer clientId=producer-1] Connection with /0.0.0.0 disconnected
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_201]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_201]
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:216) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:531) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.poll(Selector.java:483) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:539) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244) [kafka-clients-2.3.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
2020-05-17 19:53:06.210 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Node -1 disconnected.
2020-05-17 19:53:06.210 WARN 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Connection to node -1 (/0.0.0.0:9092) could not be established. Broker may not be available.
2020-05-17 19:53:06.210 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Give up sending metadata request since no node is available
2020-05-17 19:53:06.265 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Give up sending metadata request since no node is available
2020-05-17 19:53:06.319 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initialize connection to node 0.0.0.0:9092 (id: -1 rack: null) for sending metadata request
2020-05-17 19:53:06.320 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initiating connection to node 0.0.0.0:9092 (id: -1 rack: null) using address /0.0.0.0
2020-05-17 19:53:06.320 DEBUG 15739 --- [ad | producer-1] o.apache.kafka.common.network.Selector : [Producer clientId=producer-1] Connection with /0.0.0.0 disconnected
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_201]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_201]
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:216) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:531) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.poll(Selector.java:483) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:539) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244) [kafka-clients-2.3.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
2020-05-17 19:53:06.320 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Node -1 disconnected.
2020-05-17 19:53:06.320 WARN 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Connection to node -1 (/0.0.0.0:9092) could not be established. Broker may not be available.
2020-05-17 19:53:06.320 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Give up sending metadata request since no node is available
2020-05-17 19:53:06.375 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Give up sending metadata request since no node is available
2020-05-17 19:53:06.427 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initialize connection to node 0.0.0.0:9092 (id: -1 rack: null) for sending metadata request
2020-05-17 19:53:06.427 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Initiating connection to node 0.0.0.0:9092 (id: -1 rack: null) using address /0.0.0.0
2020-05-17 19:53:06.427 DEBUG 15739 --- [ad | producer-1] o.apache.kafka.common.network.Selector : [Producer clientId=producer-1] Connection with /0.0.0.0 disconnected
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_201]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_201]
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:216) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:531) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.common.network.Selector.poll(Selector.java:483) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:539) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:335) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244) [kafka-clients-2.3.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
2020-05-17 19:53:06.427 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Node -1 disconnected.
2020-05-17 19:53:06.427 WARN 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Connection to node -1 (/0.0.0.0:9092) could not be established. Broker may not be available.
2020-05-17 19:53:06.427 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Give up sending metadata request since no node is available
2020-05-17 19:53:06.482 DEBUG 15739 --- [ad | producer-1] org.apache.kafka.clients.Netwo
Replace KAFKA_ADVERTISED_HOST_NAME with KAFKA_ADVERTISED_LISTENERS, add KAFKA_LISTENERS and expose the ports correctly:
kafka:
image: wurstmeister/kafka
ports:
- 9092:9092
environment:
KAFKA_LISTENERS: PLAINTEXT://:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
Connect to localhost:9092:
spring:
kafka:
producer:
bootstrap-servers: localhost:9092
bootstrap-servers: 0.0.0.0:9092
0.0.0.0 is an invalid IP address on the client side.
0.0.0.0 on the server side means listen on all interfaces.
You must use the actual address; presumably 10.200.10.1:9092.

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.

Spring Webclient connection not closed properly

I am trying to make HTTP calls using Springboot-Reactive webclient. I am getting connection closed by remote server error.
Please find the following code which uses Webclient to make rest call.
Mono<String> post(String url, JSONObject body) {
Mono<String> result = webClient().post().uri(url)
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(body))
.exchange().log()
.flatMap { clientResponse ->
return clientResponse.bodyToMono(String.class)
}
return result
}
Webclient created code:
WebClient webClient() {
TcpClient tcpClient = TcpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000)
.doOnConnected { connection ->
connection.addHandlerLast(new LoggingHandler(LogLevel.TRACE))
connection.addHandlerLast(new ReadTimeoutHandler(30))
.addHandlerLast(new WriteTimeoutHandler(30))
}
tcpClient.wiretap(true)
ReactorClientHttpConnector httpConnector = new ReactorClientHttpConnector(HttpClient.from(tcpClient))
return WebClient.builder()
.clientConnector(httpConnector)
.build()
}
I am getting the following logs after the first call:
2019-04-10 15:26:31.534 INFO 235344 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-04-10 15:26:31.534 INFO 235344 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-04-10 15:26:31.544 INFO 235344 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 10 ms
2019-04-10 15:26:31.820 DEBUG 235344 --- [nio-8080-exec-2] reactor.netty.tcp.TcpResources : [tcp] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-tcp, daemon=true, selectCount=4, workerCount=4}
2019-04-10 15:26:31.821 DEBUG 235344 --- [nio-8080-exec-2] reactor.netty.tcp.TcpResources : [tcp] resources will use the default ConnectionProvider: PooledConnectionProvider {name=tcp, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$377/205810452#3af356f}
2019-04-10 15:26:32.127 DEBUG 235344 --- [nio-8080-exec-2] r.netty.resources.DefaultLoopEpoll : Default Epoll support : false
2019-04-10 15:26:32.128 DEBUG 235344 --- [nio-8080-exec-2] r.netty.resources.DefaultLoopKQueue : Default KQueue support : false
2019-04-10 15:26:32.131 DEBUG 235344 --- [nio-8080-exec-2] i.n.channel.MultithreadEventLoopGroup : -Dio.netty.eventLoopThreads: 8
2019-04-10 15:26:32.161 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.nio.NioEventLoop : -Dio.netty.noKeySetOptimization: false
2019-04-10 15:26:32.161 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.nio.NioEventLoop : -Dio.netty.selectorAutoRebuildThreshold: 512
2019-04-10 15:26:32.165 DEBUG 235344 --- [nio-8080-exec-2] i.netty.util.internal.PlatformDependent : org.jctools-core.MpscChunkedArrayQueue: available
2019-04-10 15:26:32.297 INFO 235344 --- [nio-8080-exec-2] reactor.Mono.SwitchIfEmpty.1 : onSubscribe(FluxSwitchIfEmpty.SwitchIfEmptySubscriber)
2019-04-10 15:26:32.316 INFO 235344 --- [nio-8080-exec-2] reactor.Mono.SwitchIfEmpty.1 : request(unbounded)
2019-04-10 15:26:32.362 DEBUG 235344 --- [nio-8080-exec-2] io.netty.handler.ssl.OpenSsl : netty-tcnative not in the classpath; OpenSslEngine will be unavailable.
2019-04-10 15:26:32.903 DEBUG 235344 --- [nio-8080-exec-2] io.netty.handler.ssl.JdkSslContext : Default protocols (JDK): [TLSv1.2, TLSv1.1, TLSv1]
2019-04-10 15:26:32.903 DEBUG 235344 --- [nio-8080-exec-2] io.netty.handler.ssl.JdkSslContext : Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA]
2019-04-10 15:26:32.929 DEBUG 235344 --- [nio-8080-exec-2] r.n.resources.PooledConnectionProvider : Creating new client pool [tcp] for remoteserver.host.com:443
2019-04-10 15:26:32.945 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.DefaultChannelId : -Dio.netty.processId: 235344 (auto-detected)
2019-04-10 15:26:33.242 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.DefaultChannelId : -Dio.netty.machineId: 1c:4d:70:ff:fe:a5:c9:6d (auto-detected)
2019-04-10 15:26:33.287 DEBUG 235344 --- [nio-8080-exec-2] io.netty.buffer.ByteBufUtil : -Dio.netty.allocator.type: pooled
2019-04-10 15:26:33.287 DEBUG 235344 --- [nio-8080-exec-2] io.netty.buffer.ByteBufUtil : -Dio.netty.threadLocalDirectBufferSize: 0
2019-04-10 15:26:33.287 DEBUG 235344 --- [nio-8080-exec-2] io.netty.buffer.ByteBufUtil : -Dio.netty.maxThreadLocalCharBufferSize: 16384
2019-04-10 15:26:33.309 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca] Created new pooled channel, now 0 active connections and 1 inactive connections
2019-04-10 15:26:33.343 DEBUG 235344 --- [ctor-http-nio-4] io.netty.buffer.AbstractByteBuf : -Dio.netty.buffer.checkAccessible: true
2019-04-10 15:26:33.344 DEBUG 235344 --- [ctor-http-nio-4] io.netty.buffer.AbstractByteBuf : -Dio.netty.buffer.checkBounds: true
2019-04-10 15:26:33.346 DEBUG 235344 --- [ctor-http-nio-4] i.n.util.ResourceLeakDetectorFactory : Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector#403ca90
2019-04-10 15:26:33.374 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.tcp.SslProvider : [id: 0xb38d8bca] SSL enabled using engine SSLEngineImpl and SNI remoteserver.host.com:443
2019-04-10 15:26:33.386 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.channel.BootstrapHandlers : [id: 0xb38d8bca] Initialized pipeline DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.sslReader = reactor.netty.tcp.SslProvider$SslReadHandler), (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-04-10 15:26:33.617 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.maxCapacityPerThread: 4096
2019-04-10 15:26:33.618 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.maxSharedCapacityFactor: 2
2019-04-10 15:26:33.618 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.linkCapacity: 16
2019-04-10 15:26:33.618 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.ratio: 8
2019-04-10 15:26:33.648 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Registering pool release on close event for channel
2019-04-10 15:26:33.648 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel connected, now 1 active connections and 0 inactive connections
2019-04-10 15:26:33.855 DEBUG 235344 --- [ctor-http-nio-4] io.netty.handler.ssl.SslHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
2019-04-10 15:26:33.857 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}, [connected])
2019-04-10 15:26:33.887 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(GET{uri=/, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [configured])
2019-04-10 15:26:33.890 DEBUG 235344 --- [ctor-http-nio-4] r.netty.http.client.HttpClientConnect : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Handler is being applied: {uri=https://remoteserver.host.com/api/v1/Test, method=POST}
2019-04-10 15:26:34.014 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object DefaultHttpRequest(decodeResult: success, version: HTTP/1.1)
POST /api/v1/Test HTTP/1.1
user-agent: ReactorNetty/0.8.6.RELEASE
host: remoteserver.host.com
Accept: application/json;charset=UTF-8
Content-Type: application/json
Content-Length: 28
2019-04-10 15:26:34.043 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object
2019-04-10 15:26:34.050 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object EmptyLastHttpContent
2019-04-10 15:26:34.051 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [request_sent])
2019-04-10 15:26:34.229 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [LoggingHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.254 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [ReadTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.271 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [WriteTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.274 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [IdleStateHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, IdleStateHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.289 DEBUG 235344 --- [ctor-http-nio-4] r.n.http.client.HttpClientOperations : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Received response (auto-read:false) : [Transfer-Encoding=chunked, Content-Type=application/json; charset=utf-8, Server=Kestrel, Server-Timing=api;desc=dotREZ API;dur=7, cache;desc=Cache read/write;ct=1;dur=1, total;dur=8, X-Powered-By=ASP.NET, Set-Cookie=dtCookie=17$0D7C3AB4BE87B44D72811D72E8C4878F; Path=/; Domain=.test.com, Date=Wed, 10 Apr 2019 21:26:37 GMT, Set-Cookie=dotrez=67235850.20480.0000; path=/; Httponly; Secure]
2019-04-10 15:26:34.289 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [response_received])
2019-04-10 15:26:34.295 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.1 : onNext(org.springframework.web.reactive.function.client.DefaultClientResponse#5119d40e)
2019-04-10 15:26:34.337 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.channel.FluxReceive : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Subscribing inbound receiver [pending: 0, cancelled:false, inboundDone: false]
2019-04-10 15:26:34.338 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | onSubscribe([Fuseable] FluxMapFuseable.MapFuseableSubscriber)
2019-04-10 15:26:34.338 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | request(unbounded)
2019-04-10 15:26:34.338 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.1 : onComplete()
2019-04-10 15:26:34.346 DEBUG 235344 --- [ctor-http-nio-4] r.n.http.client.HttpClientOperations : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Received last HTTP packet
2019-04-10 15:26:34.347 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | onNext({"data":{"result"}})
2019-04-10 15:26:34.354 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | onComplete()
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: LoggingHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: ReadTimeoutHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: WriteTimeoutHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: IdleStateHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [disconnecting])
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Releasing channel
2019-04-10 15:26:34.356 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel cleaned, now 0 active connections and 1 inactive connections
The connection becomes inactive and when I make the call after some time (say 10 mins). I am getting the following log:
2019-04-10 15:34:27.178 INFO 235344 --- [nio-8080-exec-5] reactor.Mono.SwitchIfEmpty.3 : onSubscribe(FluxSwitchIfEmpty.SwitchIfEmptySubscriber)
2019-04-10 15:34:27.179 INFO 235344 --- [nio-8080-exec-5] reactor.Mono.SwitchIfEmpty.3 : request(unbounded)
2019-04-10 15:34:27.184 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel acquired, now 1 active connections and 0 inactive connections
2019-04-10 15:34:27.184 DEBUG 235344 --- [ctor-http-nio-4] r.netty.http.client.HttpClientConnect : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Handler is being applied: {uri=https://remoteserver.host.com/api/v1/Test, method=POST}
2019-04-10 15:34:27.185 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object DefaultHttpRequest(decodeResult: success, version: HTTP/1.1)
POST /api/v1/Test HTTP/1.1
user-agent: ReactorNetty/0.8.6.RELEASE
host: remoteserver.host.com
Accept: application/json;charset=UTF-8
Content-Type: application/json
Content-Length: 28
2019-04-10 15:34:27.187 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object
2019-04-10 15:34:27.187 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object EmptyLastHttpContent
2019-04-10 15:34:27.188 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [request_sent])
2019-04-10 15:34:27.188 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [LoggingHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:27.189 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [ReadTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:27.189 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [WriteTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:27.189 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [IdleStateHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, IdleStateHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:46.395 WARN 235344 --- [ctor-http-nio-4] r.netty.http.client.HttpClientConnect : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] The connection observed an error
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[na:1.8.0_201]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[na:1.8.0_201]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_201]
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_201]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_201]
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[netty-buffer-4.1.34.Final.jar:4.1.34.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1125) ~[netty-buffer-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347) ~[netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148) ~[netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [netty-common-4.1.34.Final.jar:4.1.34.Final]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
2019-04-10 15:34:46.396 ERROR 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.3 : onError(java.io.IOException: An existing connection was forcibly closed by the remote host)
2019-04-10 15:34:46.397 ERROR 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.3 :
java.io.IOException: An existing connection was forcibly closed by the remote host
2019-04-10 15:34:46.398 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel cleaned, now 0 active connections and 1 inactive connections
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel closed, now 0 active connections and 0 inactive connections
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: LoggingHandler, context: ChannelHandlerContext(LoggingHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: ReadTimeoutHandler, context: ChannelHandlerContext(ReadTimeoutHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: WriteTimeoutHandler, context: ChannelHandlerContext(WriteTimeoutHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: IdleStateHandler, context: ChannelHandlerContext(IdleStateHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.414 ERROR 235344 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] threw exception
I see that the connection is not returning to the pool properly. Is there anything I am missing in configuration? Do I have close the connection properly? I assume this should be handled by netty right?
This question seems similar to an issue reported to the reactor-netty project.
It's not clear at this point if the remote server is not closing the connection properly, or if there is/was a bug in reactor-netty that would not manage the connection in the pool as expected.
If this happens still on recent reactor-netty versions, please update this question and/or raise an issue with a tcpdump record and wire logging to help us figure this out.

Springboot Webclient throws "An existing connection was forcibly closed by the remote host."

Springboot Webclient throws "An existing connection was forcibly closed by the remote host" error when trying to call rest api in remote server.
When the server loads, the first server request loads fine. When I send the second request after some time (Say 5 mins), I am getting the error.
Webclient creation code:
WebClient webClient() {
TcpClient tcpClient = TcpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30000)
.option(ChannelOption.SO_KEEPALIVE, false)
.doOnConnected { connection ->
connection.addHandlerLast(new LoggingHandler(LogLevel.TRACE))
connection.addHandlerLast(new ReadTimeoutHandler(30))
.addHandlerLast(new WriteTimeoutHandler(30))
.addHandlerLast(new IdleStateHandler(30,30,30))
}
ReactorClientHttpConnector httpConnector = new ReactorClientHttpConnector(HttpClient.from(tcpClient))
return WebClient.builder()
.clientConnector(httpConnector)
.build()
}
Please find the logs below. It looks like the connection is not properly closed.
Could you please let me know how to resolve it?
2019-04-10 15:26:31.534 INFO 235344 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-04-10 15:26:31.534 INFO 235344 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-04-10 15:26:31.544 INFO 235344 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 10 ms
2019-04-10 15:26:31.820 DEBUG 235344 --- [nio-8080-exec-2] reactor.netty.tcp.TcpResources : [tcp] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-tcp, daemon=true, selectCount=4, workerCount=4}
2019-04-10 15:26:31.821 DEBUG 235344 --- [nio-8080-exec-2] reactor.netty.tcp.TcpResources : [tcp] resources will use the default ConnectionProvider: PooledConnectionProvider {name=tcp, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$377/205810452#3af356f}
2019-04-10 15:26:32.127 DEBUG 235344 --- [nio-8080-exec-2] r.netty.resources.DefaultLoopEpoll : Default Epoll support : false
2019-04-10 15:26:32.128 DEBUG 235344 --- [nio-8080-exec-2] r.netty.resources.DefaultLoopKQueue : Default KQueue support : false
2019-04-10 15:26:32.131 DEBUG 235344 --- [nio-8080-exec-2] i.n.channel.MultithreadEventLoopGroup : -Dio.netty.eventLoopThreads: 8
2019-04-10 15:26:32.161 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.nio.NioEventLoop : -Dio.netty.noKeySetOptimization: false
2019-04-10 15:26:32.161 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.nio.NioEventLoop : -Dio.netty.selectorAutoRebuildThreshold: 512
2019-04-10 15:26:32.165 DEBUG 235344 --- [nio-8080-exec-2] i.netty.util.internal.PlatformDependent : org.jctools-core.MpscChunkedArrayQueue: available
2019-04-10 15:26:32.297 INFO 235344 --- [nio-8080-exec-2] reactor.Mono.SwitchIfEmpty.1 : onSubscribe(FluxSwitchIfEmpty.SwitchIfEmptySubscriber)
2019-04-10 15:26:32.316 INFO 235344 --- [nio-8080-exec-2] reactor.Mono.SwitchIfEmpty.1 : request(unbounded)
2019-04-10 15:26:32.362 DEBUG 235344 --- [nio-8080-exec-2] io.netty.handler.ssl.OpenSsl : netty-tcnative not in the classpath; OpenSslEngine will be unavailable.
2019-04-10 15:26:32.903 DEBUG 235344 --- [nio-8080-exec-2] io.netty.handler.ssl.JdkSslContext : Default protocols (JDK): [TLSv1.2, TLSv1.1, TLSv1]
2019-04-10 15:26:32.903 DEBUG 235344 --- [nio-8080-exec-2] io.netty.handler.ssl.JdkSslContext : Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA]
2019-04-10 15:26:32.929 DEBUG 235344 --- [nio-8080-exec-2] r.n.resources.PooledConnectionProvider : Creating new client pool [tcp] for remoteserver.host.com:443
2019-04-10 15:26:32.945 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.DefaultChannelId : -Dio.netty.processId: 235344 (auto-detected)
2019-04-10 15:26:33.242 DEBUG 235344 --- [nio-8080-exec-2] io.netty.channel.DefaultChannelId : -Dio.netty.machineId: 1c:4d:70:ff:fe:a5:c9:6d (auto-detected)
2019-04-10 15:26:33.287 DEBUG 235344 --- [nio-8080-exec-2] io.netty.buffer.ByteBufUtil : -Dio.netty.allocator.type: pooled
2019-04-10 15:26:33.287 DEBUG 235344 --- [nio-8080-exec-2] io.netty.buffer.ByteBufUtil : -Dio.netty.threadLocalDirectBufferSize: 0
2019-04-10 15:26:33.287 DEBUG 235344 --- [nio-8080-exec-2] io.netty.buffer.ByteBufUtil : -Dio.netty.maxThreadLocalCharBufferSize: 16384
2019-04-10 15:26:33.309 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca] Created new pooled channel, now 0 active connections and 1 inactive connections
2019-04-10 15:26:33.343 DEBUG 235344 --- [ctor-http-nio-4] io.netty.buffer.AbstractByteBuf : -Dio.netty.buffer.checkAccessible: true
2019-04-10 15:26:33.344 DEBUG 235344 --- [ctor-http-nio-4] io.netty.buffer.AbstractByteBuf : -Dio.netty.buffer.checkBounds: true
2019-04-10 15:26:33.346 DEBUG 235344 --- [ctor-http-nio-4] i.n.util.ResourceLeakDetectorFactory : Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector#403ca90
2019-04-10 15:26:33.374 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.tcp.SslProvider : [id: 0xb38d8bca] SSL enabled using engine SSLEngineImpl and SNI remoteserver.host.com:443
2019-04-10 15:26:33.386 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.channel.BootstrapHandlers : [id: 0xb38d8bca] Initialized pipeline DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.sslReader = reactor.netty.tcp.SslProvider$SslReadHandler), (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-04-10 15:26:33.617 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.maxCapacityPerThread: 4096
2019-04-10 15:26:33.618 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.maxSharedCapacityFactor: 2
2019-04-10 15:26:33.618 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.linkCapacity: 16
2019-04-10 15:26:33.618 DEBUG 235344 --- [ctor-http-nio-4] io.netty.util.Recycler : -Dio.netty.recycler.ratio: 8
2019-04-10 15:26:33.648 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Registering pool release on close event for channel
2019-04-10 15:26:33.648 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel connected, now 1 active connections and 0 inactive connections
2019-04-10 15:26:33.855 DEBUG 235344 --- [ctor-http-nio-4] io.netty.handler.ssl.SslHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
2019-04-10 15:26:33.857 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}, [connected])
2019-04-10 15:26:33.887 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(GET{uri=/, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [configured])
2019-04-10 15:26:33.890 DEBUG 235344 --- [ctor-http-nio-4] r.netty.http.client.HttpClientConnect : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Handler is being applied: {uri=https://remoteserver.host.com/api/v1/Test, method=POST}
2019-04-10 15:26:34.014 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object DefaultHttpRequest(decodeResult: success, version: HTTP/1.1)
POST /api/v1/Test HTTP/1.1
user-agent: ReactorNetty/0.8.6.RELEASE
host: remoteserver.host.com
Accept: application/json;charset=UTF-8
Content-Type: application/json
Content-Length: 28
2019-04-10 15:26:34.043 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object
2019-04-10 15:26:34.050 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object EmptyLastHttpContent
2019-04-10 15:26:34.051 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [request_sent])
2019-04-10 15:26:34.229 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [LoggingHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.254 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [ReadTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.271 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [WriteTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.274 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [IdleStateHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, IdleStateHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:26:34.289 DEBUG 235344 --- [ctor-http-nio-4] r.n.http.client.HttpClientOperations : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Received response (auto-read:false) : [Transfer-Encoding=chunked, Content-Type=application/json; charset=utf-8, Server=Kestrel, Server-Timing=api;desc=dotREZ API;dur=7, cache;desc=Cache read/write;ct=1;dur=1, total;dur=8, X-Powered-By=ASP.NET, Set-Cookie=dtCookie=17$0D7C3AB4BE87B44D72811D72E8C4878F; Path=/; Domain=.test.com, Date=Wed, 10 Apr 2019 21:26:37 GMT, Set-Cookie=dotrez=67235850.20480.0000; path=/; Httponly; Secure]
2019-04-10 15:26:34.289 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [response_received])
2019-04-10 15:26:34.295 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.1 : onNext(org.springframework.web.reactive.function.client.DefaultClientResponse#5119d40e)
2019-04-10 15:26:34.337 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.channel.FluxReceive : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Subscribing inbound receiver [pending: 0, cancelled:false, inboundDone: false]
2019-04-10 15:26:34.338 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | onSubscribe([Fuseable] FluxMapFuseable.MapFuseableSubscriber)
2019-04-10 15:26:34.338 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | request(unbounded)
2019-04-10 15:26:34.338 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.1 : onComplete()
2019-04-10 15:26:34.346 DEBUG 235344 --- [ctor-http-nio-4] r.n.http.client.HttpClientOperations : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Received last HTTP packet
2019-04-10 15:26:34.347 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | onNext({"data":{"result"}})
2019-04-10 15:26:34.354 INFO 235344 --- [ctor-http-nio-4] reactor.Mono.MapFuseable.2 : | onComplete()
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: LoggingHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: ReadTimeoutHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: WriteTimeoutHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Removed handler: IdleStateHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [disconnecting])
2019-04-10 15:26:34.355 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Releasing channel
2019-04-10 15:26:34.356 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel cleaned, now 0 active connections and 1 inactive connections
2019-04-10 15:34:27.178 INFO 235344 --- [nio-8080-exec-5] reactor.Mono.SwitchIfEmpty.3 : onSubscribe(FluxSwitchIfEmpty.SwitchIfEmptySubscriber)
2019-04-10 15:34:27.179 INFO 235344 --- [nio-8080-exec-5] reactor.Mono.SwitchIfEmpty.3 : request(unbounded)
2019-04-10 15:34:27.184 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel acquired, now 1 active connections and 0 inactive connections
2019-04-10 15:34:27.184 DEBUG 235344 --- [ctor-http-nio-4] r.netty.http.client.HttpClientConnect : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Handler is being applied: {uri=https://remoteserver.host.com/api/v1/Test, method=POST}
2019-04-10 15:34:27.185 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object DefaultHttpRequest(decodeResult: success, version: HTTP/1.1)
POST /api/v1/Test HTTP/1.1
user-agent: ReactorNetty/0.8.6.RELEASE
host: remoteserver.host.com
Accept: application/json;charset=UTF-8
Content-Type: application/json
Content-Length: 28
2019-04-10 15:34:27.187 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object
2019-04-10 15:34:27.187 DEBUG 235344 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Writing object EmptyLastHttpContent
2019-04-10 15:34:27.188 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] onStateChange(POST{uri=/api/v1/Test, connection=PooledConnection{channel=[id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443]}}, [request_sent])
2019-04-10 15:34:27.188 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [LoggingHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:27.189 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [ReadTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:27.189 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [WriteTimeoutHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:27.189 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Added decoder [IdleStateHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, LoggingHandler, ReadTimeoutHandler, WriteTimeoutHandler, IdleStateHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0]
2019-04-10 15:34:46.395 WARN 235344 --- [ctor-http-nio-4] r.netty.http.client.HttpClientConnect : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 - R:remoteserver.host.com/xx.xxx.xxx.xxx:443] The connection observed an error
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[na:1.8.0_201]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[na:1.8.0_201]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_201]
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_201]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_201]
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[netty-buffer-4.1.34.Final.jar:4.1.34.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1125) ~[netty-buffer-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347) ~[netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148) ~[netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) [netty-transport-4.1.34.Final.jar:4.1.34.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [netty-common-4.1.34.Final.jar:4.1.34.Final]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
2019-04-10 15:34:46.396 ERROR 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.3 : onError(java.io.IOException: An existing connection was forcibly closed by the remote host)
2019-04-10 15:34:46.397 ERROR 235344 --- [ctor-http-nio-4] reactor.Mono.SwitchIfEmpty.3 :
java.io.IOException: An existing connection was forcibly closed by the remote host
2019-04-10 15:34:46.398 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel cleaned, now 0 active connections and 1 inactive connections
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] r.n.resources.PooledConnectionProvider : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Channel closed, now 0 active connections and 0 inactive connections
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: LoggingHandler, context: ChannelHandlerContext(LoggingHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: ReadTimeoutHandler, context: ChannelHandlerContext(ReadTimeoutHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: WriteTimeoutHandler, context: ChannelHandlerContext(WriteTimeoutHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.399 DEBUG 235344 --- [ctor-http-nio-4] reactor.netty.ReactorNetty : [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443] Non Removed handler: IdleStateHandler, context: ChannelHandlerContext(IdleStateHandler, [id: 0xb38d8bca, L:/xx.xxx.x.xxx:55712 ! R:remoteserver.host.com/xx.xxx.xxx.xxx:443]), pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (LoggingHandler = io.netty.handler.logging.LoggingHandler), (ReadTimeoutHandler = io.netty.handler.timeout.ReadTimeoutHandler), (WriteTimeoutHandler = io.netty.handler.timeout.WriteTimeoutHandler), (IdleStateHandler = io.netty.handler.timeout.IdleStateHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2019-04-10 15:34:46.414 ERROR 235344 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] threw exception

Resources