NativeWebSocket icon indicating copy to clipboard operation
NativeWebSocket copied to clipboard

Unity android build mysteriously stopped connecting to server, editor works fine

Open dskill opened this issue 3 years ago • 3 comments

I have a confusing problem where my Unity android build mysteriously stopped connecting to my glitch server. Earlier today, it worked fine. As of this evening, it silently fails without any output. For reference, this is how I'm opening my connection: websocket = new WebSocket("ws://" + m_ServerIp, new Dictionary<string, string>() { { "User-Agent", "Unity3D" } }); but websocket.OnOpen() or websocket.OnError() are never called.

The code itself hasn't changed. So I'm running on weird theories like my android device updated itself and is now blocking the connection. Or perhaps glitch has changed something on the backend that is now causing the connection to fail (again only from an android build. Everything else seems fine).

Any suggestions on what might be going wrong, or how to better debug this? The silent failure has me stumped. Thx!

dskill avatar Oct 05 '22 06:10 dskill

And.... as of this morning the android device is working again. I'm so confused :\

dskill avatar Oct 05 '22 15:10 dskill

Glitch turns off its servers per inactivity, it can take a few minutes for Glitch to turn them on by request. This library does not have any mechanism to retry on failed connection attempts.

endel avatar Oct 05 '22 16:10 endel

I suspected something similar, but verified that I could log into the server and send/receive messages from Unity Editor and the browser during the period when my android device wasn't working.

If it happens again, is there any way to get more detailed log info about what might be happening? Thx for the response.

dskill avatar Oct 05 '22 18:10 dskill