mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-10 01:16:24 +00:00
Fix for concurrent sent issue
This commit is contained in:
parent
e142386bef
commit
474bb13204
@ -3818,7 +3818,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.
|
||||
|
@ -463,6 +463,9 @@ 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");
|
||||
_ = subscription?.ReconnectAsync();
|
||||
return;
|
||||
|
@ -336,29 +336,33 @@ namespace CryptoExchange.Net.Sockets
|
||||
_startedSent = true;
|
||||
while (true)
|
||||
{
|
||||
if (_closing)
|
||||
break;
|
||||
|
||||
_sendEvent.WaitOne();
|
||||
|
||||
if (_closing)
|
||||
break;
|
||||
|
||||
if (!_sendBuffer.TryDequeue(out var data))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
await _socket.SendAsync(new ArraySegment<byte>(data, 0, data.Length), WebSocketMessageType.Text, true, _ctsSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// cancelled
|
||||
break;
|
||||
}
|
||||
catch (WebSocketException wse)
|
||||
|
||||
while (_sendBuffer.TryDequeue(out var data))
|
||||
{
|
||||
// Connection closed unexpectedly
|
||||
Handle(errorHandlers, wse);
|
||||
await CloseInternalAsync(false, true).ConfigureAwait(false);
|
||||
break;
|
||||
try
|
||||
{
|
||||
log.Write(LogLevel.Debug, "Sending " + Encoding.UTF8.GetString(data));
|
||||
await _socket.SendAsync(new ArraySegment<byte>(data, 0, data.Length), WebSocketMessageType.Text, true, _ctsSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// cancelled
|
||||
break;
|
||||
}
|
||||
catch (WebSocketException wse)
|
||||
{
|
||||
// Connection closed unexpectedly
|
||||
Handle(errorHandlers, wse);
|
||||
await CloseInternalAsync(false, true).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user