mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-09-03 06:01:40 +00:00
Added check in websocket for receiving 401 unauthorized http response status when 101 was expected
This commit is contained in:
parent
6156fb8154
commit
3e1b5ada69
@ -1,6 +1,7 @@
|
|||||||
using CryptoExchange.Net.Interfaces;
|
using CryptoExchange.Net.Interfaces;
|
||||||
using CryptoExchange.Net.Logging.Extensions;
|
using CryptoExchange.Net.Logging.Extensions;
|
||||||
using CryptoExchange.Net.Objects;
|
using CryptoExchange.Net.Objects;
|
||||||
|
using CryptoExchange.Net.Objects.Errors;
|
||||||
using CryptoExchange.Net.Objects.Sockets;
|
using CryptoExchange.Net.Objects.Sockets;
|
||||||
using CryptoExchange.Net.RateLimiting;
|
using CryptoExchange.Net.RateLimiting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -252,6 +253,11 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
await (OnConnectRateLimited?.Invoke() ?? Task.CompletedTask).ConfigureAwait(false);
|
await (OnConnectRateLimited?.Invoke() ?? Task.CompletedTask).ConfigureAwait(false);
|
||||||
return new CallResult(new ServerRateLimitError(we.Message, we));
|
return new CallResult(new ServerRateLimitError(we.Message, we));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_socket.HttpStatusCode == HttpStatusCode.Unauthorized)
|
||||||
|
{
|
||||||
|
return new CallResult(new ServerError(new ErrorInfo(ErrorType.Unauthorized, "Server returned status code `401` when `101` was expected")));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// ClientWebSocket.HttpStatusCode is only available in .NET6+ https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket.httpstatuscode?view=net-8.0
|
// ClientWebSocket.HttpStatusCode is only available in .NET6+ https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket.httpstatuscode?view=net-8.0
|
||||||
// Try to read 429 from the message instead
|
// Try to read 429 from the message instead
|
||||||
|
Loading…
x
Reference in New Issue
Block a user