diff --git a/CryptoExchange.Net/Sockets/SocketConnection.cs b/CryptoExchange.Net/Sockets/SocketConnection.cs index 2964fbf..20bef25 100644 --- a/CryptoExchange.Net/Sockets/SocketConnection.cs +++ b/CryptoExchange.Net/Sockets/SocketConnection.cs @@ -629,7 +629,11 @@ namespace CryptoExchange.Net.Sockets return new CallResult(true); } - if (_subscriptions.Any(s => s.Authenticated)) + bool anyAuthenticated = false; + lock (_subscriptionLock) + anyAuthenticated = _subscriptions.Any(s => s.Authenticated); + + if (anyAuthenticated) { // If we reconnected a authenticated connection we need to re-authenticate var authResult = await ApiClient.AuthenticateSocketAsync(this).ConfigureAwait(false);