You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was previously able to reproduce this issue, but I have a workaround in my code that makes it less likely to occur. The use case for the exception was relatively large number of incoming MESSAGE EventType (200-300 per sec) being handled by the client. Looking at the code, this has to be some kind of race condition because the exception is occurring on a parameter (m_PreviousFrames) that was only provided from one location (DraftHybi10DataReader) and appears to be checked for null and checked to be at least the size necessary for the indexing that is required in WebSocketCommandInfo where the exception occurs. Since the only time "m_PreviousFrames" is set to null is just after the path for the crash, I'm assuming that a different frame has already started processing (and had to be non-null to even get on this path).
Looking at WebSocket.cs, it seems that in the OnDataReceived method, there is a loop used to process all "WebSocketCommandInfo" that the CommandReader has. I'm guessing with lower load, this loop breaks early and doesn't cause a problem. Also, since the "m_PreviousFrames" parameter is checked, the race condition has a very small window to occur.
Let me know if there is any more useful information that I can provide.
Here is the stacktrace:
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at SuperSocket.ClientEngine.Protocol.ArraySegmentList1[[System.Byte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].CopyTo(Byte[], Int32, Int32, Int32) at WebSocket4Net.WebSocketCommandInfo..ctor(System.Collections.Generic.IList1<WebSocket4Net.Protocol.WebSocketDataFrame>)
at WebSocket4Net.Protocol.DraftHybi10DataReader.GetCommandInfo(Byte[], Int32, Int32, Int32 ByRef)
at WebSocket4Net.WebSocket.OnDataReceived(Byte[], Int32, Int32)
at WebSocket4Net.WebSocket.client_DataReceived(System.Object, SuperSocket.ClientEngine.DataEventArgs)
at SuperSocket.ClientEngine.ClientSession.OnDataReceived(Byte[], Int32, Int32)
at SuperSocket.ClientEngine.SslStreamTcpSession.OnDataRead(System.IAsyncResult)
at System.Net.LazyAsyncResult.Complete(IntPtr)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
at System.Net.Security._SslStream.ProcessFrameBody(Int32, Byte[], Int32, Int32, System.Net.AsyncProtocolRequest)
at System.Net.Security.SslStream.ReadFrameCallback(System.Net.AsyncProtocolRequest)
at System.Net.AsyncProtocolRequest.CompleteRequest(Int32)
at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32)
at System.Net.FixedSizeReader.ReadCallback(System.IAsyncResult)
at System.Net.LazyAsyncResult.Complete(IntPtr)
at System.Net.ContextAwareResult.CompleteCallback(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.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Net.ContextAwareResult.Complete(IntPtr)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped)
at System.Threading.IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped)
The text was updated successfully, but these errors were encountered:
I was previously able to reproduce this issue, but I have a workaround in my code that makes it less likely to occur. The use case for the exception was relatively large number of incoming MESSAGE EventType (200-300 per sec) being handled by the client. Looking at the code, this has to be some kind of race condition because the exception is occurring on a parameter (m_PreviousFrames) that was only provided from one location (DraftHybi10DataReader) and appears to be checked for null and checked to be at least the size necessary for the indexing that is required in WebSocketCommandInfo where the exception occurs. Since the only time "m_PreviousFrames" is set to null is just after the path for the crash, I'm assuming that a different frame has already started processing (and had to be non-null to even get on this path).
Looking at WebSocket.cs, it seems that in the OnDataReceived method, there is a loop used to process all "WebSocketCommandInfo" that the CommandReader has. I'm guessing with lower load, this loop breaks early and doesn't cause a problem. Also, since the "m_PreviousFrames" parameter is checked, the race condition has a very small window to occur.
Let me know if there is any more useful information that I can provide.
Here is the stacktrace:
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at SuperSocket.ClientEngine.Protocol.ArraySegmentList
1[[System.Byte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].CopyTo(Byte[], Int32, Int32, Int32) at WebSocket4Net.WebSocketCommandInfo..ctor(System.Collections.Generic.IList
1<WebSocket4Net.Protocol.WebSocketDataFrame>)at WebSocket4Net.Protocol.DraftHybi10DataReader.GetCommandInfo(Byte[], Int32, Int32, Int32 ByRef)
at WebSocket4Net.WebSocket.OnDataReceived(Byte[], Int32, Int32)
at WebSocket4Net.WebSocket.client_DataReceived(System.Object, SuperSocket.ClientEngine.DataEventArgs)
at SuperSocket.ClientEngine.ClientSession.OnDataReceived(Byte[], Int32, Int32)
at SuperSocket.ClientEngine.SslStreamTcpSession.OnDataRead(System.IAsyncResult)
at System.Net.LazyAsyncResult.Complete(IntPtr)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
at System.Net.Security._SslStream.ProcessFrameBody(Int32, Byte[], Int32, Int32, System.Net.AsyncProtocolRequest)
at System.Net.Security.SslStream.ReadFrameCallback(System.Net.AsyncProtocolRequest)
at System.Net.AsyncProtocolRequest.CompleteRequest(Int32)
at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32)
at System.Net.FixedSizeReader.ReadCallback(System.IAsyncResult)
at System.Net.LazyAsyncResult.Complete(IntPtr)
at System.Net.ContextAwareResult.CompleteCallback(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.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Net.ContextAwareResult.Complete(IntPtr)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped)
at System.Threading.IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped)
The text was updated successfully, but these errors were encountered: