mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 08:26:20 +00:00
Fix for Message not handled when closing subscription, fix for reconnect loop
This commit is contained in:
parent
41f17d0378
commit
c815fad135
@ -250,7 +250,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// <inheritdoc />
|
||||
public virtual async Task ReconnectAsync()
|
||||
{
|
||||
if (_processState != ProcessState.Processing)
|
||||
if (_processState != ProcessState.Processing && IsOpen)
|
||||
return;
|
||||
|
||||
_log.Write(LogLevel.Debug, $"Socket {Id} reconnect requested");
|
||||
|
@ -385,7 +385,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
if (!subscriptions.Contains(subscription))
|
||||
return;
|
||||
|
||||
subscriptions.Remove(subscription);
|
||||
subscription.Closed = true;
|
||||
}
|
||||
|
||||
if (Status == SocketStatus.Closing || Status == SocketStatus.Closed || Status == SocketStatus.Disposed)
|
||||
@ -407,7 +407,7 @@ namespace CryptoExchange.Net.Sockets
|
||||
return;
|
||||
}
|
||||
|
||||
shouldCloseConnection = subscriptions.All(r => !r.UserSubscription);
|
||||
shouldCloseConnection = subscriptions.All(r => !r.UserSubscription || r.Closed);
|
||||
if (shouldCloseConnection)
|
||||
Status = SocketStatus.Closing;
|
||||
}
|
||||
@ -417,6 +417,9 @@ namespace CryptoExchange.Net.Sockets
|
||||
log.Write(LogLevel.Debug, $"Socket {SocketId} closing as there are no more subscriptions");
|
||||
await CloseAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
lock (subscriptionLock)
|
||||
subscriptions.Remove(subscription);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -48,6 +48,11 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// </summary>
|
||||
public bool Authenticated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether we're closing this subscription and a socket connection shouldn't be kept open for it
|
||||
/// </summary>
|
||||
public bool Closed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cancellation token registration, should be disposed when subscription is closed. Used for closing the subscription with
|
||||
/// a provided cancelation token
|
||||
|
Loading…
x
Reference in New Issue
Block a user