diff --git a/src/DotNetty.Codecs.Http/WebSockets/WebSocket08FrameDecoder.cs b/src/DotNetty.Codecs.Http/WebSockets/WebSocket08FrameDecoder.cs index 0dfc9737..691353a0 100644 --- a/src/DotNetty.Codecs.Http/WebSockets/WebSocket08FrameDecoder.cs +++ b/src/DotNetty.Codecs.Http/WebSockets/WebSocket08FrameDecoder.cs @@ -448,6 +448,7 @@ void ProtocolViolation(IChannelHandlerContext ctx, IByteBuffer input, CorruptedW if (this.receivedClosingHandshake) { closeMessage = Unpooled.Empty; + ctx.Channel.CloseAsync(); } else { @@ -455,8 +456,8 @@ void ProtocolViolation(IChannelHandlerContext ctx, IByteBuffer input, CorruptedW var errMsg = ex.Message; ICharSequence reasonText = !string.IsNullOrWhiteSpace(errMsg) ? new StringCharSequence(errMsg) : closeStatus.ReasonText; closeMessage = new CloseWebSocketFrame(closeStatus, reasonText); + _ = ctx.WriteAndFlushAsync(closeMessage).CloseOnComplete(ctx.Channel); } - _ = ctx.WriteAndFlushAsync(closeMessage).CloseOnComplete(ctx.Channel); } ExceptionDispatchInfo.Capture(ex).Throw(); }