socket.io-unity icon indicating copy to clipboard operation
socket.io-unity copied to clipboard

Socket Connection Disconnects and Reconnects (Sometimes)

Open Lt23live opened this issue 3 years ago • 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!"); }

Lt23live avatar May 22 '21 01:05 Lt23live

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.

zombiestruck avatar May 26 '21 21:05 zombiestruck

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

Lt23live avatar May 26 '21 22:05 Lt23live

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 :)

zombiestruck avatar May 26 '21 22:05 zombiestruck

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

caolmad avatar May 29 '23 21:05 caolmad