mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-10 17:36:19 +00:00
Prevent reconnect spamming when invalid checksum
This commit is contained in:
parent
84c16a5dc5
commit
f9957cba16
@ -3576,6 +3576,11 @@
|
||||
The topic of the update, what symbol/asset etc..
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CryptoExchange.Net.Sockets.DataEvent`1.Event">
|
||||
<summary>
|
||||
The event that triggered the update
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CryptoExchange.Net.Sockets.DataEvent`1.OriginalData">
|
||||
<summary>
|
||||
The original data that was received, only available when OutputOriginalData is set to true in the client options
|
||||
@ -3594,13 +3599,14 @@
|
||||
<param name="data">The new data</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:CryptoExchange.Net.Sockets.DataEvent`1.As``1(``0,System.String)">
|
||||
<member name="M:CryptoExchange.Net.Sockets.DataEvent`1.As``1(``0,System.String,System.String)">
|
||||
<summary>
|
||||
Create a new DataEvent with data in the from of type K based on the current DataEvent. OriginalData and Timestamp will be copied over
|
||||
</summary>
|
||||
<typeparam name="K">The type of the new data</typeparam>
|
||||
<param name="data">The new data</param>
|
||||
<param name="topic">The new topic</param>
|
||||
<param name="event">The new event</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:CryptoExchange.Net.Sockets.MessageEvent">
|
||||
@ -3794,6 +3800,11 @@
|
||||
Socket subscription
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CryptoExchange.Net.Sockets.SocketSubscription.Id">
|
||||
<summary>
|
||||
Subscription id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="E:CryptoExchange.Net.Sockets.SocketSubscription.Exception">
|
||||
<summary>
|
||||
Exception event
|
||||
@ -3940,7 +3951,9 @@
|
||||
<member name="M:CryptoExchange.Net.Sockets.WebsocketFactory.CreateWebsocket(CryptoExchange.Net.Logging.Log,System.String,System.Collections.Generic.IDictionary{System.String,System.String},System.Collections.Generic.IDictionary{System.String,System.String})">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:System.Diagnostics.CodeAnalysis.AllowNullAttribute">
|
||||
</members>
|
||||
</doc>
|
||||
System.Diagnostics.CodeAnalysis.AllowNullAttribute">
|
||||
<summary>
|
||||
Specifies that <see langword="null"/> is allowed as an input even if the
|
||||
corresponding type disallows it.
|
||||
|
@ -39,6 +39,7 @@ namespace CryptoExchange.Net.OrderBook
|
||||
private readonly bool strictLevels;
|
||||
private readonly bool validateChecksum;
|
||||
|
||||
private bool _stopProcessing;
|
||||
private Task? _processTask;
|
||||
private readonly AutoResetEvent _queueEvent;
|
||||
private readonly ConcurrentQueue<object> _processQueue;
|
||||
@ -255,7 +256,7 @@ namespace CryptoExchange.Net.OrderBook
|
||||
{
|
||||
log.Write(LogLevel.Warning, $"{Id} order book {Symbol} disconnected");
|
||||
Status = OrderBookStatus.Disconnected;
|
||||
StopAsync();
|
||||
_ = StopAsync();
|
||||
};
|
||||
|
||||
subscription.ConnectionRestored += async time => await ResyncAsync().ConfigureAwait(false);
|
||||
@ -379,6 +380,12 @@ namespace CryptoExchange.Net.OrderBook
|
||||
if (Status == OrderBookStatus.Disconnected)
|
||||
break;
|
||||
|
||||
if (_stopProcessing)
|
||||
{
|
||||
log.Write(LogLevel.Trace, $"Skipping message because of resubscribing");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item is InitialOrderBookItem iobi)
|
||||
ProcessInitialOrderBookItem(iobi);
|
||||
if (item is ProcessQueueItem pqi)
|
||||
@ -473,10 +480,8 @@ namespace CryptoExchange.Net.OrderBook
|
||||
|
||||
if(!checksumResult)
|
||||
{
|
||||
// Reconnects the socket, also closing other subscriptions on that socket.
|
||||
// Should maybe only reconnect the specific subscription?
|
||||
|
||||
log.Write(LogLevel.Warning, $"{Id} order book {Symbol} out of sync. Resyncing");
|
||||
_stopProcessing = true;
|
||||
Resubscribe();
|
||||
return;
|
||||
}
|
||||
@ -490,6 +495,7 @@ namespace CryptoExchange.Net.OrderBook
|
||||
{
|
||||
await subscription!.UnsubscribeAsync().ConfigureAwait(false);
|
||||
Reset();
|
||||
_stopProcessing = false;
|
||||
if (!await subscription!.ResubscribeAsync().ConfigureAwait(false))
|
||||
{
|
||||
// Resubscribing failed, reconnect the socket
|
||||
|
@ -7,6 +7,9 @@ namespace CryptoExchange.Net.Sockets
|
||||
/// </summary>
|
||||
public class SocketSubscription
|
||||
{
|
||||
/// <summary>
|
||||
/// Subscription id
|
||||
/// </summary>
|
||||
public int Id { get; }
|
||||
/// <summary>
|
||||
/// Exception event
|
||||
|
Loading…
x
Reference in New Issue
Block a user