Check websocket state before closing
This commit is contained in:
parent
e47d121985
commit
dab8e15052
|
@ -93,8 +93,12 @@ using Microsoft.Extensions.Logging;
|
||||||
} while (socket.State == WebSocketState.Open && result.MessageType != WebSocketMessageType.Close);
|
} while (socket.State == WebSocketState.Open && result.MessageType != WebSocketMessageType.Close);
|
||||||
|
|
||||||
|
|
||||||
|
if (webSocketContext.State == WebSocketState.Open)
|
||||||
|
{
|
||||||
await webSocketContext.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
|
await webSocketContext.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
|
||||||
result.CloseStatusDescription, _disposeCancellationToken);
|
result.CloseStatusDescription, _disposeCancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
socket.Dispose();
|
socket.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user