Skip to content

Commit

Permalink
Merge pull request #4965 from rvullriede/fix/adjust-logging
Browse files Browse the repository at this point in the history
fix: reduce log level for conection reset
  • Loading branch information
timmolter authored Nov 19, 2024
2 parents b69fd62 + 4dc1f0d commit 586be46
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
import org.slf4j.LoggerFactory;

public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object> {

private static final Logger LOG = LoggerFactory.getLogger(WebSocketClientHandler.class);
private final StringBuilder currentMessage = new StringBuilder();

public interface WebSocketMessageHandler {

public void onMessage(String message);
}

Expand Down Expand Up @@ -114,15 +116,24 @@ private void dealWithContinuation(ContinuationWebSocketFrame frame) {

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
LOG.error(
"WebSocket client {} encountered exception ({} - {}). Closing",
ctx.channel(),
cause.getClass().getSimpleName(),
cause.getMessage(),
cause);
if (cause.getMessage() != null && cause.getMessage().toLowerCase()
.contains("connection reset")) {
LOG.warn(
"WebSocket client {} encountered exception ({} - {}). Closing",
ctx.channel(),
cause.getClass().getSimpleName(),
cause.getMessage());
} else {
LOG.error(
"WebSocket client {} encountered exception ({} - {}). Closing",
ctx.channel(),
cause.getClass().getSimpleName(),
cause.getMessage(),
cause);
}
if (!handshakeFuture.isDone()) {
handshakeFuture.setFailure(cause);
}
ctx.close();
}
}
}

0 comments on commit 586be46

Please sign in to comment.