1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-12-18 04:37:01 +00:00

Update HighPerfWebSocketClient.cs

This commit is contained in:
Jkorf 2025-12-15 08:49:25 +01:00
parent 8720130990
commit 0b1cf9086c

View File

@ -145,7 +145,9 @@ namespace CryptoExchange.Net.Sockets.HighPerf
catch (Exception e) catch (Exception e)
{ {
if (ct.IsCancellationRequested) if (ct.IsCancellationRequested)
{
_logger.SocketConnectingCanceled(Id); _logger.SocketConnectingCanceled(Id);
}
else if (!_ctsSource.IsCancellationRequested) else if (!_ctsSource.IsCancellationRequested)
{ {
// if _ctsSource was canceled this was already logged // if _ctsSource was canceled this was already logged
@ -271,10 +273,12 @@ namespace CryptoExchange.Net.Sockets.HighPerf
try try
{ {
if (_socket!.State == WebSocketState.CloseReceived) if (_socket!.State == WebSocketState.CloseReceived)
await _socket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Closing", default).ConfigureAwait(false);
else if (_socket.State == WebSocketState.Open)
{ {
await _socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", default).ConfigureAwait(false); await _socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", default).ConfigureAwait(false);
}
else if (_socket.State == WebSocketState.Open)
{
await _socket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Closing", default).ConfigureAwait(false);
var startWait = DateTime.UtcNow; var startWait = DateTime.UtcNow;
while (_processing && _socket.State != WebSocketState.Closed && _socket.State != WebSocketState.Aborted) while (_processing && _socket.State != WebSocketState.Closed && _socket.State != WebSocketState.Aborted)