1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-17 11:23:00 +00:00

feature: Handle error 429 when connecting websocket (#213)

* feature: Handle error 429 when connecting websocket

* Add preprocessor directive for NET6_0_OR_GREATER when checking for connection rate limit
This commit is contained in:
Jonnern
2024-09-24 12:50:59 +02:00
committed by GitHub
parent fee18fd183
commit 5d3de52da6
10 changed files with 94 additions and 5 deletions
@@ -22,6 +22,7 @@ namespace CryptoExchange.Net.Logging.Extensions
private static readonly Action<ILogger, Exception?> _disposingSocketClient;
private static readonly Action<ILogger, int, int, Exception?> _unsubscribingSubscription;
private static readonly Action<ILogger, int, Exception?> _reconnectingAllConnections;
private static readonly Action<ILogger, DateTime, Exception?> _addingRetryAfterGuard;
static SocketApiClientLoggingExtension()
{
@@ -104,6 +105,11 @@ namespace CryptoExchange.Net.Logging.Extensions
LogLevel.Information,
new EventId(3017, "ReconnectingAll"),
"Reconnecting all {ConnectionCount} connections");
_addingRetryAfterGuard = LoggerMessage.Define<DateTime>(
LogLevel.Warning,
new EventId(3018, "AddRetryAfterGuard"),
"Adding RetryAfterGuard ({RetryAfter}) because the connection attempt was rate limited");
}
public static void FailedToAddSubscriptionRetryOnDifferentConnection(this ILogger logger, int socketId)
@@ -185,5 +191,10 @@ namespace CryptoExchange.Net.Logging.Extensions
{
_reconnectingAllConnections(logger, connectionCount, null);
}
public static void AddingRetryAfterGuard(this ILogger logger, DateTime retryAfter)
{
_addingRetryAfterGuard(logger, retryAfter, null);
}
}
}