Skip to content

Unhandled Exception in WebSocket4Net.WebSocket.OnConnected() at 0.15.2 #204

@jercymat

Description

@jercymat

System: Windows Server 2022
Library Version: 0.15.2.11

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at WebSocket4Net.Protocol.DraftHybi10Processor.SendHandshake(WebSocket4Net.WebSocket)
   at WebSocket4Net.WebSocket.OnConnected()
   at WebSocket4Net.WebSocket.client_Connected(System.Object, System.EventArgs)
   at SuperSocket.ClientEngine.ClientSession.OnConnected()
   at SuperSocket.ClientEngine.AsyncTcpSession.OnGetSocket(System.Net.Sockets.SocketAsyncEventArgs)
   at SuperSocket.ClientEngine.TcpClientSession.ProcessConnect(System.Net.Sockets.Socket, System.Object, System.Net.Sockets.SocketAsyncEventArgs, System.Exception)
   at SuperSocket.ClientEngine.ConnectAsyncExtension.SocketAsyncEventCompleted(System.Object, System.Net.Sockets.SocketAsyncEventArgs)
   at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(System.Net.Sockets.SocketAsyncEventArgs)
   at System.Net.Sockets.SocketAsyncEventArgs.ExecutionCallback(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.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError, Int32, System.Net.Sockets.SocketFlags)
   at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

Our app crashed due to the unhandled exception. Seems like the exception occurred here:

ProtocolProcessor.SendHandshake(this);

#80 have the similar issue and a simple exception handling might work just like it did here:
try
{
ProtocolProcessor.SendCloseHandshake(this, statusCode, reason);
}
catch (Exception e)
{
if (Client != null)
{
OnError(e);
}
}

As the new 1.x.x version didn't support .NET framework, a fix on this version would be great:)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions