Page 8 of 8

Re: Server dropping UDP packets

Posted: 26 Mar 2020, 12:45
by Mrm83
Lapo wrote:Can you give us more details?
100% packets missing after the initial initUDP call?
Or after a certain amount of activity?

Are there long pauses during which the client is not sending or receiving any UDP packets? If that's the case it could be a matter of adding a small keep alive call between client and server to avoid the client silently recycle the ephemeral port (if no transmission is seen for a while).

Let us know
You are right, inactivity is the cause.

Will add a UDP keep alive packet.

How long does it take before the port is recycled?
Is it also possible to detect port being recycled on client side so the user can be disconnected?

Re: Server dropping UDP packets

Posted: 26 Mar 2020, 14:56
by Lapo
Mrm83 wrote: How long does it take before the port is recycled?
That is a good question :) Unfortunately I don't know as each OS handles this differently. From our tests it can can take from 90 to 300 seconds of inactivity.
I would recommend sending a simple "ping" request from client to server every 20 seconds and I am not sure a reply from the server is even necessary. So you could just discard it from server side.
Is it also possible to detect port being recycled on client side so the user can be disconnected?
No, this stuff is not reported by the OS. However if you keep the UDP channel alive there will be no recycling.

Hope it helps

p.s. = the issue has also been reported by another developer a few weeks ago. We'll add an UDP keep-alive system in our API with the next server update.

Re: Server dropping UDP packets

Posted: 02 Apr 2020, 14:07
by Mrm83
I just found another issue regarding UDP.

If user disconnects and reconnects, all UDP calls will be broken as well. I am assuming the client's UDP got recycled during the reconnect?
How can this case be fixed?

Re: Server dropping UDP packets

Posted: 02 Apr 2020, 15:42
by Lapo
It depends what you mean by "reconnect".
Do you mean via the reconnection system? Or do you reconnect manually?

Thanks

Re: Server dropping UDP packets

Posted: 03 Apr 2020, 14:40
by Mrm83
Disrupted WIFI connection by turning off WIFI and then turning it back on.

TCP calls works once WIFI is back on, but all UDP calls were missing.

Re: Server dropping UDP packets

Posted: 03 Apr 2020, 15:44
by Lapo
Yeah disrupting the WIFI will likely kill the UDP channel.
In these cases it would be best to detect the WiFi change at OS level, destroy the current SmartFox connection and create a new one, re-establishing both TCP and UDP channels.

For more on this topic check these articles, which go in much greater details:
https://smartfoxserver.com/blog/handlin ... e-devices/

Hope it helps

Re: Server dropping UDP packets

Posted: 18 May 2020, 19:50
by vkrishna1983
Would it be possible to get a blog post around this topic?
What android OS Callbacks are we listening for? WifiState change? any state change?
How do we do this on IOS? Is this require don the desktops / laptops as well?

Re: Server dropping UDP packets

Posted: 19 May 2020, 08:25
by Lapo
My suggestion is to refer to the specific OS documentation. Every OS has its own API that notifies WIFI state changes.

Thanks