NullReferenceException from Ping()
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
I'm using the Unity package Version: 1.0.7 (Mar 07, 2014) and I've run into a problem where at some point I'm calling ws.IsAlive() and will receive
NullReferenceException: Object reference not set to an instance of an object WebSocketSharp.WebSocket.Ping (System.Byte[] frame, Int32 timeout) WebSocketSharp.WebSocket.Ping () WebSocketSharp.WebSocket.get_IsAlive ()
My code contains this bit of code
public void Update() { if(wsConnected != ws.IsAlive){ wsConnected = ws.IsAlive; if(wsConnected){ EmitEvent("connect"); } else { EmitEvent("disconnect"); } } }
which I suspect may be causing an issue when ws.Connect() is called as that call is done within a separate thread.
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 at WebSocket.get_IsAlive and the Ping methods named in the stack trace, then inspect how they interact with Connect when called from another thread. Reproduce the Update loop with the Unity package version 1.0.7 and determine whether the reported NullReferenceException can be prevented; done means IsAlive no longer throws in that scenario.
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