Spring 5 WebClient Intermittent SSLHandshakeException - spring-boot

I am seeing javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure errors with Spring WebClient using Netty. The same code has been working great connecting to various endpoints for dev work. Now we are connecting to a production environment(different target hostname) and this error is occurring. Sometimes we can go for hours or days with no issue. Or sometimes right after an app restart. Then once it starts happening all requests will fail with a SSLHandshakeException. A restart of the app fixes it usually.
I appreciate any assistance. Thank you.
Environment
Spring Boot 2.5.8
Spring WebFlux 5.3.14
io.netty 4.1.72.Final
OpenJDK 11
WebClient Configuration
WebClient is configured as a Spring Bean with the following configuration.
#Bean
protected WebClient myWebClient() {
final HttpClient httpClient = HttpClient.create()
.wiretap(HttpClient.class.getCanonicalName(), LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL, StandardCharsets.UTF_8)
.responseTimeout(Duration.ofSeconds(120));
return WebClient.builder()
.defaultHeader("sourceSystem", "source system name")
.clientConnector(new ReactorClientHttpConnector(httpClient))
.filters(exchangeFilterFunctions -> {
exchangeFilterFunctions.add(errorHandlingFilter());
})
.build();
private ExchangeFilterFunction errorHandlingFilter() {
return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> {
if(clientResponse.statusCode().isError()) {
return clientResponse.bodyToMono(String.class)
.flatMap(errorBody -> Mono.error(new MyException(clientResponse.statusCode(), extractErrorMessage(errorBody))));
} else {
return Mono.just(clientResponse);
}
});
}
HTTP POST
ResponseEntity<JsonNode> resp = webClient
.post()
.uri("https://externalurl")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.body(BodyInserters.fromValue(bodyData))
.exchangeToMono(clientResponse -> clientResponse.toEntity(JsonNode.class))
.block();
Log Messages - SUCCESS
2022-06-09 14:03:11,645 DEBUG [reactor-http-nio-2] r.netty.resources.DefaultPooledConnectionProvider: [49be2ee8-18, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] onStateChange(POST{uri=/connect/token, connection=PooledConnection{channel=[id: 0x49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443]}}, [response_received])
2022-06-09 14:03:11,646 DEBUG [reactor-http-nio-2] reactor.netty.channel.FluxReceive: [49be2ee8-18, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] FluxReceive{pending=0, cancelled=false, inboundDone=false, inboundError=null}: subscribing inbound receiver
2022-06-09 14:03:11,648 DEBUG [reactor-http-nio-2] reactor.netty.http.client.HttpClient: [49be2ee8-18, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] READ: 5B 0
2022-06-09 14:03:11,648 DEBUG [reactor-http-nio-2] reactor.netty.http.client.HttpClientOperations: [49be2ee8-18, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] Received last HTTP packet
2022-06-09 14:03:11,650 DEBUG [reactor-http-nio-2] r.netty.resources.DefaultPooledConnectionProvider: [49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] onStateChange(POST{uri=/connect/token, connection=PooledConnection{channel=[id: 0x49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443]}}, [response_completed])
2022-06-09 14:03:11,651 DEBUG [reactor-http-nio-2] reactor.netty.ReactorNetty: [49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] Removed handler: reactor.left.responseTimeoutHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.loggingHandler = reactor.netty.transport.logging.ReactorNettyLoggingHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2022-06-09 14:03:11,652 DEBUG [reactor-http-nio-2] r.netty.resources.DefaultPooledConnectionProvider: [49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] onStateChange(POST{uri=/connect/token, connection=PooledConnection{channel=[id: 0x49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443]}}, [disconnecting])
2022-06-09 14:03:11,653 DEBUG [reactor-http-nio-2] r.netty.resources.DefaultPooledConnectionProvider: [49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] Releasing channel
2022-06-09 14:03:11,654 DEBUG [reactor-http-nio-2] reactor.netty.resources.PooledConnectionProvider: [49be2ee8, L:/my-ip-address:53320 - R:external-hostname/external-ip-address:443] Channel cleaned, now: 0 active connections, 1 inactive connections and 0 pending acquire requests.
2022-06-09 14:03:11,655 DEBUG [reactor-http-nio-3] reactor.netty.resources.PooledConnectionProvider: [0b61c34f] Created a new pooled channel, now: 0 active connections, 1 inactive connections and 0 pending acquire requests.
Log Messages - FAILURE
2022-06-09 14:03:11,657 DEBUG reactor.util.Loggers$Slf4JLogger [reactor-http-nio-3] [0b61c34f] SSL enabled using engine sun.security.ssl.SSLEngineImpl#31d4d4e6 and SNI external-hostname:443
2022-06-09 14:03:11,657 DEBUG reactor.util.Loggers$Slf4JLogger [reactor-http-nio-3] [0b61c34f] Initialized pipeline DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.loggingHandler = reactor.netty.transport.logging.ReactorNettyLoggingHandler), (reactor.left.sslReader = reactor.netty.tcp.SslProvider$SslReadHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
2022-06-09 14:03:11,657 DEBUG io.netty.util.internal.logging.AbstractInternalLogger [reactor-http-nio-3] [0b61c34f] REGISTERED
2022-06-09 14:03:11,711 DEBUG reactor.util.Loggers$Slf4JLogger [reactor-http-nio-3] [0b61c34f] Connecting to [external-hostname/external-ip-address:443].
2022-06-09 14:03:11,712 DEBUG io.netty.util.internal.logging.AbstractInternalLogger [reactor-http-nio-3] [0b61c34f] CONNECT: external-hostname/external-ip-address:443
2022-06-09 14:03:11,754 DEBUG reactor.util.Loggers$Slf4JLogger [reactor-http-nio-3] [0b61c34f, L:/my-ip-address:53603 - R:external-hostname/external-ip-address:443] Registering pool release on close event for channel
2022-06-09 14:03:11,754 DEBUG reactor.util.Loggers$Slf4JLogger [reactor-http-nio-3] [0b61c34f, L:/my-ip-address:53603 - R:external-hostname/external-ip-address:443] Channel connected, now: 1 active connections, 1 inactive connections and 0 pending acquire requests.
2022-06-09 14:03:11,773 DEBUG io.netty.util.internal.logging.AbstractInternalLogger [reactor-http-nio-3] [0b61c34f, L:/my-ip-address:53603 - R:external-hostname/external-ip-address:443] ACTIVE
2022-06-09 14:03:11,802 DEBUG io.netty.util.internal.logging.AbstractInternalLogger [reactor-http-nio-3] [0b61c34f, L:/my-ip-address:53603 - R:external-hostname/external-ip-address:443] USER_EVENT: SslHandshakeCompletionEvent(javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure)
2022-06-09 14:03:11,811 WARN reactor.util.Loggers$Slf4JLogger [reactor-http-nio-3] [0b61c34f, L:/my-ip-address:53603 - R:external-hostname/external-ip-address:443] The connection observed an error
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:128)
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
at java.base/sun.security.ssl.Alert$AlertConsumer.consume(Alert.java:279)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:181)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
at java.base/sun.security.ssl.SSLEngineImpl.decode(SSLEngineImpl.java:672)
at java.base/sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:627)
at java.base/sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:443)
at java.base/sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:422)
at java.base/javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:634)
at io.netty.handler.ssl.SslHandler$SslEngineType$3.unwrap(SslHandler.java:295)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1341)
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1234)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1283)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)

Related

spring kafka: Transactions in consumer Timeout expired after 60000 milliseconds while awaiting AddOffsetsToTxn

We have a transactional producer. And there are no issue there.
For the consumer, we see the following in the logs. Question is why is a transaction being started here while we are consuming the message (and there is this resulting exception)?
2022-12-28 18:02:05.986 DEBUG [qa] 85474 --- [tainer#0-51-C-1] o.s.k.t.KafkaTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2022-12-28 18:02:10.437 DEBUG [qa] 85474 --- [tainer#0-51-C-1] o.s.k.t.KafkaTransactionManager : Created Kafka transaction on producer [CloseSafeProducer [delegate=brave.kafka.clients.TracingProducer#43e18a26]]
2022-12-28 18:02:10.438 DEBUG [qa] 85474 --- [tainer#0-51-C-1] abc.abc.kafka : NORMAL uid[n/a] cid[uPRwhWZikfcYpGfIqh7TxXFnm6VmZWkf] m[[S] Consuming message] data[record = ConsumerRecord(topic =XXXXXXX)))]
2022-12-28 18:02:10.438 DEBUG [qa] 85474 --- [tainer#0-51-C-1] abc.abc.kafka : NORMAL uid[n/a] cid[uPRwhWZikfcYpGfIqh7TxXFnm6VmZWkf] m[Processed message]
2022-12-28 18:03:10.439 INFO [qa] 85474 --- [tainer#0-51-C-1] abc.abc.common.Generic : NORMAL uid[n/a] cid[uPRwhWZikfcYpGfIqh7TxXFnm6VmZWkf] m[Throwable t] data[exception = [Ljava.lang.StackTraceElement;#6d314e1d] ex[Timeout expired after 60000 milliseconds while awaiting AddOffsetsToTxn] sts[org.apache.kafka.common.errors.TimeoutException: Timeout expired after 60000 milliseconds while awaiting AddOffsetsToTxn
]
2022-12-28 18:03:10.439 DEBUG [qa] 85474 --- [tainer#0-51-C-1] abc.abc.kafka : NORMAL uid[n/a] cid[uPRwhWZikfcYpGfIqh7TxXFnm6VmZWkf] m[[E] Consuming message]
2022-12-28 18:03:10.439 DEBUG [qa] 85474 --- [tainer#0-51-C-1] o.s.k.t.KafkaTransactionManager : Initiating transaction commit
2022-12-28 18:04:10.444 ERROR [qa] 85474 --- [tainer#0-51-C-1] o.s.k.core.DefaultKafkaProducerFactory : org.apache.kafka.common.errors.TimeoutException: Timeout expired after 60000 milliseconds while awaiting EndTxn(true)
commitTransaction failed: CloseSafeProducer [delegate=brave.kafka.clients.TracingProducer#43e18a26]
2022-12-28 18:04:10.444 DEBUG [qa] 85474 --- [tainer#0-51-C-1] o.s.k.t.KafkaTransactionManager : org.apache.kafka.common.errors.TimeoutException: Timeout expired after 60000 milliseconds while awaiting EndTxn(true)
Initiating transaction rollback after commit exception
2022-12-28 18:04:10.445 WARN [qa] 85474 --- [tainer#0-51-C-1] o.s.k.core.DefaultKafkaProducerFactory : Error during some operation; producer removed from cache: CloseSafeProducer [delegate=brave.kafka.clients.TracingProducer#43e18a26]
2022-12-28 18:04:12.436 ERROR [qa] 85474 --- [tainer#0-51-C-1] o.s.k.l.KafkaMessageListenerContainer : org.apache.kafka.common.errors.TimeoutException: Timeout expired after 60000 milliseconds while awaiting EndTxn(true)
Transaction rolled back
This is the configuration:
spring:
data:
mongodb:
uri: indb-prop
auto-index-creation: false
kafka:
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
retries: 2
client-id: ${spring.application.name}-${info.cluster}-${IP_ADDRESS}PP
transaction-id-prefix: tx-${spring.kafka.producer.client-id}-
properties:
enable.idempotence: true
spring.json.add.type.headers: false
bootstrap-servers: ${kafka_bootstrap_servers_2}
# listener:
# missing-topics-fatal: true
# type: batch
# concurrency: 15
# ack-mode: manual_immediate
# poll-timeout: 1s
consumer:
key-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
group-id: ${spring.application.name}-${info.cluster}-111111111112
client-id: ${spring.application.name}-${info.cluster}-${IP_ADDRESS}
# client-id: ${spring.kafka.consumer.group-id}-${IP_ADDRESS}
auto-offset-reset: earliest
enable-auto-commit: false
isolation-level: read_committed
# max-poll-records: 3
fetch-max-wait: 5s
properties:
max.poll.interval.ms: 20000000
spring.json.trusted.packages: '*'
spring.deserializer.key.delegate.class: org.apache.kafka.common.serialization.StringDeserializer
spring.deserializer.value.delegate.class: org.springframework.kafka.support.serializer.JsonDeserializer
spring.json.value.default.type: net.abc.abc.EventData
bootstrap-servers: ${kafka_bootstrap_servers}
And the consumer:
#KafkaListener(
topics = "SOME_TOPIC",
autoStartup = "true")
// #Transactional(transactionManager = "mongoTransactionManager", propagation = Propagation.REQUIRED)
#Override
public void onMessage(ConsumerRecord<String, EventData> data) {
if (data == null || data.value() == null) {
return;
}
logger.debug(m -> m.event(KAFKA)
.msg("[S] Consuming message")
.with("record", data));
try {
logger.debug(m -> m.event(KAFKA)
.msg("Processed message"));
}
finally {
logger.debug(m -> m.event(KAFKA)
.msg("[E] Consuming message"));
}
The springBoot version: '2.6.6'
How many broker nodes are you using? If 1, have you overridden the broker params KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR and KAFKA_TRANSACTION_STATE_LOG_MIN_ISR to 1?
Similar sounding issue here:
https://github.com/testcontainers/testcontainers-java/issues/1816
Rob.

PrematureCloseException: Connection prematurely closed

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);
}

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