kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
752 stars 272 forks source link

NullReferenceException at WebSocket4Net.Protocol.DraftHybi10Processor.SendMessage #113

Closed drweeto closed 6 years ago

drweeto commented 6 years ago

The following exception was raised recently:

websocket4net_nullreferenceexception

My websocket connection was closed (from the target end), triggering the Closed event. I then disposed of the websocket object and created a new websocket object. This time, the websocket could not reach the target (HTTP 520 Origin Error), the Closed event triggered. I disposed the websocket object again and then recreated the websocket, this time it did connect. But then a few seconds later my program crashed.

Are you able to tell if this is something I've caused? Perhaps I am doing something wrong regarding disposal of websocket objects.

WebSocket4NET: v0.15.0 SuperSocket.ClientEngine.Core: v0.8.0.13

purpleriboflavin commented 6 years ago

I have the exact same issue, same version, same everything.

Ashthos commented 6 years ago

Similar issue for me:

WebSocket4Net: 0.15.0

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at WebSocket4Net.Protocol.DraftHybi10Processor.SendMessage(WebSocket websocket, Int32 opCode, String message) at WebSocket4Net.WebSocket.OnDataReceived(Byte[] data, Int32 offset, Int32 length) at SuperSocket.ClientEngine.AsyncTcpSession.ProcessReceive(SocketAsyncEventArgs e) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.QueueUserWorkItemCallbackDefaultContext.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()System.NullReferenceException: Object reference not set to an instance of an object. at WebSocket4Net.Protocol.DraftHybi10Processor.SendMessage(WebSocket websocket, Int32 opCode, String message) at WebSocket4Net.WebSocket.OnDataReceived(Byte[] data, Int32 offset, Int32 length) at SuperSocket.ClientEngine.AsyncTcpSession.ProcessReceive(SocketAsyncEventArgs e) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.QueueUserWorkItemCallbackDefaultContext.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()

kerryjiang commented 6 years ago

Ok, I will get time to check this issue.

kerryjiang commented 6 years ago

Could you try the new released version? https://www.nuget.org/packages/WebSocket4Net/0.15.1

drweeto commented 6 years ago

Thank you very much! I should be able to try it out in parallel with the old version this week. I will post up how it goes if no one else gets back to you before me.

drweeto commented 6 years ago

Apologies for the delay. The new version seems to fix the reported error. Thank you very much for providing the update. I will close this issue now.