Server dropping UDP packets

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Mrm83
Posts: 155
Joined: 17 Dec 2017, 04:02

Re: Server dropping UDP packets

Postby Mrm83 » 26 Mar 2020, 12:45

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?
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server dropping UDP packets

Postby Lapo » 26 Mar 2020, 14:56

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.
Lapo
--
gotoAndPlay()
...addicted to flash games
Mrm83
Posts: 155
Joined: 17 Dec 2017, 04:02

Re: Server dropping UDP packets

Postby Mrm83 » 02 Apr 2020, 14:07

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?
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server dropping UDP packets

Postby Lapo » 02 Apr 2020, 15:42

It depends what you mean by "reconnect".
Do you mean via the reconnection system? Or do you reconnect manually?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Mrm83
Posts: 155
Joined: 17 Dec 2017, 04:02

Re: Server dropping UDP packets

Postby Mrm83 » 03 Apr 2020, 14:40

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.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server dropping UDP packets

Postby Lapo » 03 Apr 2020, 15:44

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
Lapo

--

gotoAndPlay()

...addicted to flash games
vkrishna1983
Posts: 3
Joined: 18 May 2020, 19:39

Re: Server dropping UDP packets

Postby vkrishna1983 » 18 May 2020, 19:50

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?
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server dropping UDP packets

Postby Lapo » 19 May 2020, 08:25

My suggestion is to refer to the specific OS documentation. Every OS has its own API that notifies WIFI state changes.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 54 guests