graphql-client
graphql-client copied to clipboard
6.0.1 - System.ObjectDisposedException (SendWebSocketMessageAsync)
My app suddenly went boom along with the following exception. Not entirely sure how/where to properly catch it. Most probably during sending a Pong ( my app never actively send anything itself, only runs a subscription and receive events )
Description: The process was terminated due to an unhandled exception. Exception Info: System.ObjectDisposedException at System.Net.WebSockets.WebSocketBase.ThrowIfDisposed() at System.Net.WebSockets.WebSocketBase+WebSocketOperation+<Process>d__19.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at System.Net.WebSockets.WebSocketBase+<SendAsyncCore>d__47.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at GraphQL.Client.Http.Websocket.GraphQLHttpWebSocket+<SendWebSocketMessageAsync>d__39.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at GraphQL.Client.Http.Websocket.GraphQLHttpWebSocket+<SendWebSocketRequestAsync>d__38.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at GraphQL.Client.Http.Websocket.GraphQLTransportWSProtocolHandler+<>c__DisplayClass7_1`1+<<CreateSubscriptionObservable>b__2>d[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()
I've just had another app crash of the same type and this time around I noticed it happened sometime around when the graphClient was restarted, which happens when the access token gets renewed ( typically once every hour ). This access token is sent in the init() phase and needs to be updated on expiry. So to accomplish this I simply dispose the running client and it's subscriptions ( events, ws state and ws exceptions ), and set it all up again.