Rocher0724 / socket.io-unity

MIT License
107 stars 19 forks source link

Socket Connection Disconnects and Reconnects (Sometimes) #15

Open Lt23live opened 3 years ago

Lt23live commented 3 years ago

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!"); }

zombiestruck commented 3 years ago

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.

Lt23live commented 3 years ago

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

zombiestruck commented 3 years ago

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

caolmad commented 1 year ago

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