Smartfox could not detect idle connections

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

Moderators: Lapo, Bax

pratts
Posts: 34
Joined: 23 Aug 2016, 17:46

Smartfox could not detect idle connections

Postby pratts » 07 Sep 2017, 11:07

Hello,

I have set up a game server using smartfox and I am listening for USER_DISCONNECT, USER_RECONNECTION_TRY and USER_RECONNECTION_SUCCESS events on both zone and room level. I connected two client, one from wifi and other from 4G network (mobile data). During gameplay, I turned off wifi and both mobile network. Server detected the disconnection for user on mobile data after 5-10 seconds and did not detect/trigger any of the disconnection event related to user from wifi.

Below mentioned are the configurations of server.xml and zone.xml:
1. server.xml
<sessionMaxIdleTime>20</sessionMaxIdleTime>
<userMaxIdleTime>300</userMaxIdleTime>

2. zone xml file
<userReconnectionSeconds>10</userReconnectionSeconds>
<overrideMaxUserIdleTime>30</overrideMaxUserIdleTime>

I expected server to detect inactivity and disconnection to be detected after staying idle for 30+10=40 seconds, but that did not happen. I can recreate the case everytime I disconnect the user from wifi.

Smartfox version : 2.9.2
OS : Centos 6.1
Note : Turning off wifi is not the actual disconnection as per the smartfox documentation. But inactivity could be detected.
Can you provide any help in this issue ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox could not detect idle connections

Postby Lapo » 07 Sep 2017, 16:03

Hi,
this is possibly the most recurring topic on this board :)
We have discussed many times. See here for instance:
viewtopic.php?f=18&t=19689&hilit=wifi+disconnection

If there's any other question let me know.
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
pratts
Posts: 34
Joined: 23 Aug 2016, 17:46

Re: Smartfox could not detect idle connections

Postby pratts » 07 Sep 2017, 16:58

Thank you for replying.
As I mentioned opening/closing a connection requires message exchange. If that's not possible a disconnection will not occur, and both sides of the communication will keep "thinking" that the connection is active.


I get that in case of wifi disconnection, server will not be able to detect disconnection immediately. And probably the disconnection detection that we observed was due because the server OS detected it. This is similar to unplugging the LAN wire from the system.

Then what about the max user idle time settings in xml file in zone xml file. Shouldn't the server treat the user as disconnected because no packet was sent from user during that duration ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox could not detect idle connections

Postby Lapo » 08 Sep 2017, 07:50

Hi,
pratts wrote:Then what about the max user idle time settings in xml file in zone xml file. Shouldn't the server treat the user as disconnected because no packet was sent from user during that duration ?

I am not able to reproduce this issue.
Connecting a client to the server and then shutting down the client's wifi doesn't change the server behavior, which shuts down the connection after the number of seconds configured in the Zone.

I have tested using two machines in the same network and using 30 seconds as the "idle timer". The only difference is that I tested with the latest SFS2X 2.13 while you're running a pretty old version.

I'd suggest you try to install 2.13 in another folder and test under the same conditions and with the same client.
http://smartfoxserver.com/download/sfs2x#p=installer

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
pratts
Posts: 34
Joined: 23 Aug 2016, 17:46

Re: Smartfox could not detect idle connections

Postby pratts » 08 Sep 2017, 10:42

I tested this issue with 2 mobiles (each on different network) and server was on a different network too. We could not recreate this issue on our office network.
Our live server is busy running games at the same time.
Will these steps make any difference to it ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox could not detect idle connections

Postby Lapo » 08 Sep 2017, 10:50

Yes, they will.
It is possible that the server cannot disconnect the client when the timer expires due to a different state in the underlying TCP. My suspect is that over the internet the connection goes into CLOSE_WAIT state which in turn doesn't trigger a disconnection at application level (the server).

Typically this is just a matter of time before the internal TCP timeout triggers and the disconnection finally happens.
Lapo

--

gotoAndPlay()

...addicted to flash games
pratts
Posts: 34
Joined: 23 Aug 2016, 17:46

Re: Smartfox could not detect idle connections

Postby pratts » 08 Sep 2017, 11:52

It simply means that the state of the TCP connection did not change for it to be cleared by the smartfox server at application level. Even after the session idle time passed, the state remained same. That's why the timeout did not work.
After 17 minutes, the TCP connection was closed on OS side and it triggered the USER_DISCONNECT event on smartfox side.

Correct me if I am wrong.

One more thing, can we do nothing to track this inactivity on smartfox side since we depend upon those events ?

How does ghost hunter work in this case ? Will it help us to detect such connections ?

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 78 guests