1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-10 17:36:19 +00:00

Small fix when closing socket

This commit is contained in:
Jan Korf 2022-05-08 16:25:45 +02:00
parent 1c8cf5ac98
commit 5683ae0b3c

View File

@ -280,8 +280,14 @@ namespace CryptoExchange.Net.Sockets
_sendEvent.Set();
if (_socket.State == WebSocketState.Open)
await _socket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Closing", default).ConfigureAwait(false);
{
try
{
await _socket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Closing", default).ConfigureAwait(false);
}
catch(Exception)
{ } // Can sometimes throw an exception when socket is in aborted state due to timing
}
log.Write(LogLevel.Debug, $"Socket {Id} closed");
Handle(closeHandlers);
}