-
Notifications
You must be signed in to change notification settings - Fork 134
Description
I am getting an ObjectDisposedException with the stack trace below caught and logged by my apps which handles TaskScheduler.UnobservedTaskException. once this happen the websocket stops working.
at System.Net.WebSockets.BrowserWebSocket.ThrowIfDisposed()
at System.Net.WebSockets.BrowserWebSocket.get_SubProtocol()
at System.Net.WebSockets.ClientWebSocket.get_SubProtocol()
at Websocket.Client.DisconnectionInfo.Create(DisconnectionType type, WebSocket client, Exception exception)
at Websocket.Client.WebsocketClient.StartClient(Uri uri, CancellationToken token, ReconnectionType type, Boolean failFast)
at Websocket.Client.WebsocketClient.Reconnect(ReconnectionType type, Boolean failFast, Exception causedException)
at Websocket.Client.WebsocketClient.ReconnectSynchronized(ReconnectionType type, Boolean failFast, Exception causedException)
I believe this is the sequence of events that is causing this
- It needs to reconnect for some reason.
- It disposes the old client here
- It calls to StartClient a few lines later
- It tries to recreate the connection here but that throws an exception
- That exception is caught and the very first line uses the client that has been disposed
- Its used in the DisonnectionInfo constructor where it throws ObjectDisposedException
- This means it never makes it to the line restarting the _errorReconnectTimer here