Rocher0724/socket.io-unity

Socket Connection Disconnects and Reconnects (Sometimes)

Opened this issue · 4 comments

When connecting to our server it sometimes takes very long to connect. And after some time it disconnects, then reconnects. It also has an issue recieving messages.

socket.On("chat message", OnChat);

private void OnChat(object obj)
{
Debug.Log("Got Chat!");
}

I can confirm I am experiencing the disconnect and reconnect issue. I have not experienced the other two issues. As it occasionally disconnects before sending a packet leading to a packet being dropped, this can be pretty annoying.

I'm using socket.io 2.0.4 and Unity 2021.1.0f1.

It seems to occur every 35 seconds.

Actually its the exact same issue for me. Socket IO 4 and Unity 2020.3x LTS. Thank you for being more descriptive than i was :D

image
Time is in ms.
This seems to be a duplicate of #4
image
Upon further investigation of issue, they seem to both boil down to an incorrect response to the ping. Changing the ping interval to be more frequent (10000ms) with a ping timeout of 5000 results in disconnects every 15 seconds.

The socket.io docs show a default ping timeout of 5000ms and ping interval of 25000 seconds. This explains the 30 second disconnect issues.

@Rocher0724 This should allow you to fix both issues and close them :)

Hello, has anyone found a solution to this problem? :(