diff --git a/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java b/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java index 156d03d81ce..954d4d960a3 100644 --- a/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java +++ b/xchange-stream-service-netty/src/main/java/info/bitrich/xchangestream/service/netty/WebSocketClientHandler.java @@ -19,10 +19,12 @@ import org.slf4j.LoggerFactory; public class WebSocketClientHandler extends SimpleChannelInboundHandler { + private static final Logger LOG = LoggerFactory.getLogger(WebSocketClientHandler.class); private final StringBuilder currentMessage = new StringBuilder(); public interface WebSocketMessageHandler { + public void onMessage(String message); } @@ -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(); } -} +} \ No newline at end of file