Binance.Net icon indicating copy to clipboard operation
Binance.Net copied to clipboard

Uncatched exception on the newest version

Open NektoDron opened this issue 2 years ago • 11 comments

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, Dictionary2 parameters, Boolean signed, HttpMethodParameterPosition parameterPosition, ArrayParametersSerialization arraySerialization, Int32 requestId, Dictionary2 additionalHeaders) at CryptoExchange.Net.RestClient.SendRequestAsync[T](Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary2 parameters, Boolean signed, Boolean checkResult, Nullable1 parameterPosition, Nullable1 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()

NektoDron avatar Dec 25 '21 07:12 NektoDron

Hi . You have to set your ApiKey

kamranhuseyns avatar Dec 26 '21 21:12 kamranhuseyns

Hi, it was set. It happens if connection was lost

NektoDron avatar Dec 27 '21 07:12 NektoDron

Hi, is this with alpha1 or alpha2?

JKorf avatar Dec 27 '21 09:12 JKorf

release 7.2.6 execution - net 6.0

NektoDron avatar Dec 27 '21 09:12 NektoDron

Do you have any additional logging? Do you have any connectionlost/restored handling?

JKorf avatar Jan 14 '22 12:01 JKorf

Additional logging was disabled. Connectionlost/restored handling has only SubscribeToUserDataUpdatesAsync stream. if connection lost will be initiated full reconnection (new BinanceSocketClient will be created).

NektoDron avatar Jan 14 '22 13:01 NektoDron

Can you show me how that code works?

JKorf avatar Jan 14 '22 13:01 JKorf

It disposes the BinanceClient and BinanceSocketClient and makes new instances.

NektoDron avatar Feb 14 '22 07:02 NektoDron

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?

JKorf avatar Feb 14 '22 08:02 JKorf

Because it was written before reconnection handling appeared, and worked fine some years.

NektoDron avatar Feb 14 '22 08:02 NektoDron

And it disposed not on ConnectionLost. It disposed if some abnormal error was happened. For example, invalid listen key in KeepAliveUserStreamAsync call.

NektoDron avatar Feb 14 '22 08:02 NektoDron