Binance.Net
Binance.Net copied to clipboard
Uncatched exception on the newest version
13:07:13.31[2]FATAL:UnobservedTaskException: AggregateException: InvalidOperationException:The WebSocket is not connected.:Exception:
The WebSocket is not connected.
System.InvalidOperationException
Stack Trace: at System.Net.WebSockets.ClientWebSocket.get_ConnectedWebSocket() at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.ReceiveLoopAsync()
13:09:03.17[2]FATAL:UnobservedTaskException: AggregateException: ObjectDisposedException:Cannot access a disposed object. Object name: 'SecureString'.:Exception:
Cannot access a disposed object. Object name: 'SecureString'.
System.ObjectDisposedException
Stack Trace:
at System.Security.SecureString.EnsureNotDisposed()
at CryptoExchange.Net.ExtensionMethods.GetString(SecureString source)
at Binance.Net.BinanceAuthenticationProvider.AddAuthenticationToHeaders(String uri, HttpMethod method, Dictionary2 parameters, Boolean signed, HttpMethodParameterPosition parameterPosition, ArrayParametersSerialization arraySerialization) at CryptoExchange.Net.RestClient.ConstructRequest(Uri uri, HttpMethod method, Dictionary
2 parameters, Boolean signed, HttpMethodParameterPosition parameterPosition, ArrayParametersSerialization arraySerialization, Int32 requestId, Dictionary2 additionalHeaders) at CryptoExchange.Net.RestClient.SendRequestAsync[T](Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary
2 parameters, Boolean signed, Boolean checkResult, Nullable1 parameterPosition, Nullable
1 arraySerialization, Int32 credits, JsonSerializer deserializer, Dictionary`2 additionalHeaders)
at Binance.Net.SubClients.Spot.BinanceClientSpotSystem.GetServerTimeAsync(Boolean resetAutoTimestamp, CancellationToken ct)
13:09:19.26[2]FATAL:UnobservedTaskException: AggregateException: ObjectDisposedException:The CancellationTokenSource has been disposed.:Exception:
The CancellationTokenSource has been disposed.
System.ObjectDisposedException
Stack Trace: at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.SendLoopAsync()
Hi . You have to set your ApiKey
Hi, it was set. It happens if connection was lost
Hi, is this with alpha1 or alpha2?
release 7.2.6 execution - net 6.0
Do you have any additional logging? Do you have any connectionlost/restored handling?
Additional logging was disabled. Connectionlost/restored handling has only SubscribeToUserDataUpdatesAsync stream. if connection lost will be initiated full reconnection (new BinanceSocketClient will be created).
Can you show me how that code works?
It disposes the BinanceClient and BinanceSocketClient and makes new instances.
You're disposing the socket client in the ConnectionLost event? I can imagine that doesn't work. Any reason you're not using the default reconnect handling?
Because it was written before reconnection handling appeared, and worked fine some years.
And it disposed not on ConnectionLost. It disposed if some abnormal error was happened. For example, invalid listen key in KeepAliveUserStreamAsync call.