New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket does not detect network switch and not calling OnClose event #516
Comments
What command did you send? Did you find an actual solution for this issue? |
maybe somebody know how to fix this? |
Hi @ilsnk , I used the following workaround for this problem. As you can see I used
Hope it help! |
this could help but i get a different error when i try to ping. it often happens when i have a lot of clients connected to my server and the server itself is connected to another service via websocket - and this connection breaks (but not detect lose connect) and i get this error
I think i was able to fix it, not sure if this is correct but it worked for me. WebSocket.cs
private bool sendBytes (byte[] bytes)
{
try {
_stream.Write (bytes, 0, bytes.Length);
}
catch (IOException e)
{
_logger.Error (e.Message);
_logger.Error (e.ToString ());
close((ushort)CloseStatusCode.InvalidData, e.Message);
return false;
}
catch (Exception ex) {
_logger.Error (ex.Message);
_logger.Error (ex.ToString ());
return false;
}
return true;
} |
Hi, I'm using Websocket-Sharp in Unity for a turn-based game.
There is a problem on detecting lost connection in some cases when for example in mobile devices user's Internet connection changes from 4G to 3G in the middle of the game, or in Windows, user turns on/off VPN in the middle of the game.
In this situations websocket-sharp thinks that is still connected and the connection readyState is open, but actually its not, and server messages won't recieve any more and websocket-sharp won't fire OnClose event.
I found a temporary solution to fix this issue by sending a command to server every second. When the issue I mentioned above happens, after some command sending, the websocket-sharp findout that the connection is lost and fires OnClose event.
Is there any direct control on Sending ping messages in websocket-sharp?
Is there any solution for this issue?
The text was updated successfully, but these errors were encountered: