Check websocket state before closing

This commit is contained in:
Claus Vium 2019-02-27 21:48:28 +01:00
parent e47d121985
commit dab8e15052

View file

@ -93,8 +93,12 @@ using Microsoft.Extensions.Logging;
} while (socket.State == WebSocketState.Open && result.MessageType != WebSocketMessageType.Close);
await webSocketContext.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
result.CloseStatusDescription, _disposeCancellationToken);
if (webSocketContext.State == WebSocketState.Open)
{
await webSocketContext.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
result.CloseStatusDescription, _disposeCancellationToken);
}
socket.Dispose();
}
else