Fire exceptionCaught before exception-caused close for WebSockets.

Motivation:

WebSocket decoding throws exceptions on failure that should cause the
pipline to close.  These are currently ignored in the
`WebSocketProtocolHandler` and `WebSocketServerProtocolHandler`.  In
particular, this means that messages exceding the max message size will
cause the channel to close with no reported failure.

Modifications:

Re-fire the event just before closing the socket to allow it to be
handled appropriately.

Result:

Closes [#3063].
This commit is contained in:
Michael K. Werle 2017-05-01 12:48:55 -05:00 committed by Norman Maurer
parent a3e496a521
commit e70fbe316d
2 changed files with 2 additions and 0 deletions

View File

@ -39,6 +39,7 @@ abstract class WebSocketProtocolHandler extends MessageToMessageDecoder<WebSocke
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
ctx.fireExceptionCaught(cause);
ctx.close();
}
}

View File

@ -178,6 +178,7 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {
HTTP_1_1, HttpResponseStatus.BAD_REQUEST, Unpooled.wrappedBuffer(cause.getMessage().getBytes()));
ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} else {
ctx.fireExceptionCaught(cause);
ctx.close();
}
}