NullReferenceException in WebSocket.get_IsAlive () after error in socket
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
This exception we have everyday after websocket-server restart
System.NullReferenceException: Object reference not set to an instance of an object
at WebSocketSharp.WebSocket.Ping (System.Byte[] frame, Int32 timeout) [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.Ping () [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.get_IsAlive () [0x00000] in <filename unknown>:0
at WebSocketController.Stop () [0x00000] in <filename unknown>:0
at WebSocketController.OnError (System.Object sender, WebSocketSharp.ErrorEventArgs errorEventArgs) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) System.EventHandler`1<WebSocketSharp.ErrorEventArgs>:invoke_void__this___object_TEventArgs (object,WebSocketSharp.ErrorEventArgs)
at WebSocketSharp.Ext.Emit[ErrorEventArgs] (System.EventHandler`1 eventHandler, System.Object sender, WebSocketSharp.ErrorEventArgs e) [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.error (System.String message) [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket.acceptException (System.Exception exception, System.String reason) [0x00000] in <filename unknown>:0
at WebSocketSharp.WebSocket+<>c__DisplayClass18.<startReceiving>b__17 (System.Exception ex) [0x00000] in <filename unknown>:0
at WebSocketSharp.Ext+<>c__DisplayClass6.<ReadBytesAsync>b__5 (IAsyncResult ar) [0x00000] in <filename unknown>:0
Where WebSocketController.Stop() is
if (ws != null && ws.IsAlive)
{
ws.Close(CloseStatusCode.Normal, "Shutdown");
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with WebSocket.Ping and WebSocket.get_IsAlive in the stack trace, then inspect how WebSocketController.Stop calls IsAlive after an error. Reproduce the websocket-server restart sequence and verify that stopping the controller no longer raises NullReferenceException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100