I am currently encountering an issue in my Spring Boot app that uses netty client to access remote http endpoints. The error is:
2024-09-19 08:12:25.186 [reactor-http-epoll-4] ERROR d.o.c.p.api.http.GlobalControllerExceptionHandler:54 - Internal error: recvAddress(..) failed: Connection reset by peer org.springframework.web.reactive.function.client.WebClientRequestException: recvAddress(..) failed: Connection reset by peer
My investigation led to the following method, where in the case of successful connections we see in the logs Received a TLS close_notify, closing the channel now but in the case of unsuccessful connections this is not present.
|
@Override |
|
@SuppressWarnings("FutureReturnValueIgnored") |
|
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { |
|
if (evt instanceof SslCloseCompletionEvent) { |
|
SslCloseCompletionEvent sslCloseCompletionEvent = (SslCloseCompletionEvent) evt; |
|
|
|
// When a close_notify is received, the SSLHandler fires an SslCloseCompletionEvent.SUCCESS event, |
|
// so if the event is success and if the channel is still active (not closing for example), |
|
// then immediately close the channel. |
|
// see https://www.rfc-editor.org/rfc/rfc5246#section-7.2.1, which states that when receiving a close_notify, |
|
// then the connection must be closed down immediately. |
|
if (sslCloseCompletionEvent.isSuccess() && ctx.channel().isActive()) { |
|
if (log.isDebugEnabled()) { |
|
log.debug(format(ctx.channel(), "Received a TLS close_notify, closing the channel now.")); |
|
} |
|
ctx.close(); |
|
} |
|
} |
|
ReferenceCountUtil.release(evt); |
|
} |
My question is:
How difficult is it to log the cause of the unsuccessful event (if it exists)
Something like:
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof SslCloseCompletionEvent) {
SslCloseCompletionEvent sslCloseCompletionEvent = (SslCloseCompletionEvent) evt;
// When a close_notify is received, the SSLHandler fires an SslCloseCompletionEvent.SUCCESS event,
// so if the event is success and if the channel is still active (not closing for example),
// then immediately close the channel.
// see https://www.rfc-editor.org/rfc/rfc5246#section-7.2.1, which states that when receiving a close_notify,
// then the connection must be closed down immediately.
if (!sslCloseCompletionEvent.isSuccess()) {
log.debug("The channel encountered an error: ", sslCloseCompletionEvent.cause());
return; // probably even throw
}
if (sslCloseCompletionEvent.isSuccess() && ctx.channel().isActive()) {
if (log.isDebugEnabled()) {
log.debug(format(ctx.channel(), "Received a TLS close_notify, closing the channel now."));
}
ctx.close();
}
}
ReferenceCountUtil.release(evt);
}
p.s.
few points to consider here:
- the same code (exact docker image works fine in a different aws account)
- All infrastructure is almost identical. We know because we have compared the infra so many times, and we have concluded that all differences are not related to the issue (checked that by changing the different params)
I am currently encountering an issue in my Spring Boot app that uses netty client to access remote http endpoints. The error is:
My investigation led to the following method, where in the case of successful connections we see in the logs
Received a TLS close_notify, closing the channel nowbut in the case of unsuccessful connections this is not present.reactor-netty/reactor-netty-core/src/main/java/reactor/netty/channel/ChannelOperationsHandler.java
Lines 84 to 103 in 101aa02
My question is:
How difficult is it to log the cause of the unsuccessful event (if it exists)
Something like:
p.s.
few points to consider here: