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
Hi @endel
Thank you for your great work
I have tryed to resolve issue with reconnect socket that was close before
In jslib there is method WebSocketConnect
and in this method we have condition if (instance.ws !== null) {...}
but if we called close socket before, we deleted instance.ws
then I try to connect web socket again and instance.ws !== null will be always true
in this case "instance.ws" will be 'undefined', so the better condition will be '!=' not '!=='
Does it make sense?
Thank you
The text was updated successfully, but these errors were encountered:
You can easily automatically reconnected by checking the socket status and attempting to connect if it is equal to WebSocketState.Closed in a loop. (Eg. in the Update() method or with InvokeRepeating().
Edit: This worked fine on my editor, but doesn't seem to work on my Quest 2. I have to restart the app every time the websocket connection closes, even if I try to create a new websocket instance.
This approach void TryReconnect() { if (ws.State == WebSocketState.Closed) { ws.Connect(); } }
doesn't seems to work neither in Editor nor in build in my case.
I found that full deleting of WebSocket object, "unreferencing" and recreating it and reconnecting works in my case.
I also noticed that connection can be interrupted by OnApplicationFocus(false), so in this case reconecting on OnApplicationFocus(true) helps.
Hi @endel
Thank you for your great work
I have tryed to resolve issue with reconnect socket that was close before
In jslib there is method WebSocketConnect
and in this method we have condition
if (instance.ws !== null) {...}
but if we called close socket before, we deleted instance.ws
then I try to connect web socket again and
instance.ws !== null
will be always truein this case "instance.ws" will be 'undefined', so the better condition will be '!=' not '!=='
Does it make sense?
Thank you
The text was updated successfully, but these errors were encountered: