jchristn/WatsonWebsocket

Getting Error While Disconnecting a Client

Closed this issue · 8 comments

Hi,

We are getting errors very frequently while disconnecting the client. Here is the complete stack trace. Please help -

Application: XXXXXXXXXX
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.HttpListenerException
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at System.Net.WebSockets.WebSocketHttpListenerDuplexStream+d__30.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task)
at System.Net.WebSockets.WebSocketBase+WebSocketOperation+d__19.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task)
at System.Net.WebSockets.WebSocketBase+d__56.MoveNext()

Exception Info: System.Net.WebSockets.WebSocketException
at System.Net.WebSockets.WebSocketBase.ThrowIfConvertibleException(System.String, System.Exception, System.Threading.CancellationToken, Boolean)
at System.Net.WebSockets.WebSocketBase+d__56.MoveNext()

Exception Info: System.AggregateException
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean)
at System.Threading.Tasks.Task.Wait(Int32, System.Threading.CancellationToken)
at WatsonWebsocket.WatsonWsServer.DisconnectClient(System.String)
at _19_neostox_msgbroadcaster.Program+d__7.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_1(System.Object)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
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()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Thanks and regards,
Rajesh

Hi @rajeshdua123 please re-open if this does not fix the issue. Thanks for filing it!

NuGet v2.2.0.10: https://www.nuget.org/packages/WatsonWebsocket/2.2.0.10
Commit: c84681c

Thanks @jchristn.

We have recently beta launched our product and currently, 5000-5500 concurrent connections are being managed through your WebSocket program and it's a breeze.

Will share more details once we go live with all the features. Infact, if you would allow, would write best practices as to how to make the best use of WatsonWeb Socket.

Hi @rajeshdua123 that is awesome! I would love to have you and your team contribute best practices, wiki articles, anything that you think would give insight and guidance to others that are or want to use the library.

Also, if there are any capabilities that you feel would make the library better, please let me know! Cheers, Joel

Will do it for sure.

Hi @rajeshdua123 thanks for your note. I'm having difficulty reproducing this last one. Do you have a high rate of connects and disconnects? If so it could be that, since the IEnumerable is taken from a ConcurrentDictionary, that there were updates since the call to the ListClients() call vs new connects/disconnects that occurred. Let me know. Thanks!

Hi @rajeshdua123 do you have ANTS Performance Profiler? That may be the best place to start to see where in the code there is latency/CPU. If there are optimizations that would be beneficial in the library, I'd be more than happy to implement them. Feel free to email me at joel dot christner at gmail.