private void handleUnexpected(ChannelHandlerContext ctx, Throwable cause) { if (cause instanceof IOException) { String msg = cause.getMessage(); if (msg != null && msg.contains("Connection reset")) { // ignore client connection drops return; } } if (LOG.isErrorEnabled()) { LOG.error("Unexpected Exception in WebSocket [" + webSocketBean.getTarget() + "]: " + cause.getMessage(), cause); } Channel channel = ctx.channel(); if (channel.isOpen()) { final CloseReason internalError = CloseReason.INTERNAL_ERROR; writeCloseFrameAndTerminate(ctx, internalError); } }
/** * Writes the give close reason and terminates the session. * @param ctx The context * @param closeReason The reason */ protected void writeCloseFrameAndTerminate(ChannelHandlerContext ctx, CloseReason closeReason) { final int code = closeReason.getCode(); final String reason = closeReason.getReason(); writeCloseFrameAndTerminate(ctx, code, reason); }
LOG.debug("WebSocket bean [" + webSocketBean.getTarget() + "] received message, but defined no @OnMessage handler. Dropping frame..."); writeCloseFrameAndTerminate( ctx, CloseReason.UNSUPPORTED_DATA writeCloseFrameAndTerminate( ctx, CloseReason.UNSUPPORTED_DATA.getCode(), handleCloseFrame(ctx, cwsf); } else { writeCloseFrameAndTerminate( ctx, CloseReason.UNSUPPORTED_DATA