Discarding UDP packet

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

Moderators: Lapo, Bax

Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Discarding UDP packet

Postby Vcrn » 04 Aug 2018, 15:27

There is an issue we have where some players will have their UDP port change, causing all of the UDP traffic between that client and the server to be discarded. They will still have an active TCP connection, but they don't send/receive any UDP packets, which in our game gives the player an unfair advantage. We believe this can be caused by the user locking their phone or minimizing the app for a short period of time, then when the app is opened again a new UDP connection is established. We're not sure if this is caused by the device itself or due to a limitation of their cellular data network. Here are some examples of the errors:

Code: Select all

04 Aug 2018 | 10:00:03,533 | WARN  | SFSWorker:Sys:9 | v2.protocol.SFSIoHandler |     | Discard UDP packet from xxx.xxx.xxx.121:13771, reason: Sender IP doesn't match TCP session address: xxx.xxx.xxx.121 != xxx.xxx.xxx.40


Code: Select all

04 Aug 2018 | 10:03:38,546 | WARN  | SFSWorker:Sys:12 | v2.protocol.SFSIoHandler |     | Discard UDP packet from xx.xx.xxx.40:27134, reason: Sender UDP Port doesn't match current session port: 27134 != 27146


Code: Select all

04 Aug 2018 | 10:00:03,590 | WARN  | SocketWriter-1 | bitswarm.core.SocketWriter |     | java.lang.IllegalStateException: UDP Packet cannot be sent to: { Id: 1242520, Type: DEFAULT, Logged: Yes, IP: xxx.xx.xxx.18:40370 }, no DatagramChannel was ever set!
   com.smartfoxserver.bitswarm.core.SocketWriter.udpSend(SocketWriter.java:463)
   com.smartfoxserver.bitswarm.core.SocketWriter.processRegularSession(SocketWriter.java:290)
   com.smartfoxserver.bitswarm.core.SocketWriter.processSessionQueue(SocketWriter.java:217)
   com.smartfoxserver.bitswarm.core.SocketWriter.run(SocketWriter.java:193)
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   java.lang.Thread.run(Thread.java:745)


Since the issue is likely caused by the user's device or network, we know there probably isn't anything that can be done to fix it from the server side. However, is there any way we can disconnect the user when any of the above errors occurs? This would solve our issue as it only occurs to a small amount of players and it has game-breaking effects.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Discarding UDP packet

Postby Lapo » 06 Aug 2018, 08:00

Hi,
We believe this can be caused by the user locking their phone or minimizing the app for a short period of time, then when the app is opened again a new UDP connection is established.

no this is not the case. When the app is woken up it won't re-establish a UDP connection on its own.
What is likely to happen (especially on mobile) is that the original port used to communicate in UDP is changed causing the problem.

You can read about a possible solution here:
viewtopic.php?p=87135#p87135

Unfortunately it's not possible to disconnect the user that causes this error because at that point the server does not know who to disconnect. The unique port number (alongside the IP address) is needed to uniquely identify the sender.

Similarly it's not possible to disconnect from client side because there's no way to know that (under the hood) the UDP source port has been changed.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Edithgal, Stevenor and 74 guests