CustomLogin + HRC + isForceLogout

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

Moderators: Lapo, Bax

User avatar
Fraggle
Posts: 62
Joined: 02 Apr 2010, 06:41
Location: Paris, France

CustomLogin + HRC + isForceLogout

Postby Fraggle » 20 Jan 2012, 14:20

Hi,

I'm trying to handle nicely the various connexion events that may happen in my game.

From what I understand, here are the important bits:

• isForceLogout set to true in the zone config will force an existing logged in user with the same username to be disconnected if a new connexion from the same username is attempted.

• userReconnectionSeconds controls the amount of seconds that a socket will remain opened if there is a network issue between the client and the server, allowing the smartfox client lib to reconnect gracefully.


Here are the various scenarios I think might happen:

• A: User log in with a client, then log in with another client while the first one is still there.

• B: User log in with a client, a network error happen but it come back quick enough.

• C: user log in with a client, the network is disconnect long enough, the connection cannot not be re-established.


In scenari A:

With isForceLogout true and userReconnectionSeconds : 0, the first client is disconnected, the second client is connected but the login does not complete, here is a log from the server:

Code: Select all

15:09:37,750 INFO  [SocketReader] core.SocketAcceptor     - Session created: { Id: 9, Type: DEFAULT, Logged: No, IP: 10.25.0.81:52652 } on Server port: 9933 <---> 52652
15:09:38,093 INFO  [pool-1-thread-5] entities.SFSZone     - User already logged in. Disconnecting previous instance : ( User Name: seb, Id: 4, Priv: 0, Sess: 10.25.0.81:52648 )
15:09:38,094 INFO  [SocketReader] sessions.DefaultSessionManager     - Session removed: { Id: 8, Type: DEFAULT, Logged: Yes, IP: 10.25.0.81:52648 }
15:09:38,096 INFO  [SocketReader] entities.SFSZone     - User: seb was disconnected.
15:09:38,096 INFO  [SocketReader] api.SFSApi     - User disconnected: ( User Name: seb, Id: 4, Priv: 0, Sess: 10.25.0.81:52648 )
15:09:38,097 INFO  [pool-1-thread-5] sessions.DefaultSessionManager     - Session removed: { Id: 8, Type: DEFAULT, Logged: Yes, IP: 10.25.0.81:52648 }
15:09:38,097 INFO  [pool-1-thread-5] entities.SFSZone     - User: seb was disconnected.
15:09:38,098 INFO  [pool-1-thread-5] api.SFSApi     - User disconnected: ( User Name: seb, Id: 4, Priv: 0, Sess: 10.25.0.81:52648 )
15:09:38,099 WARN  [pool-1-thread-5] managers.SFSExtensionManager     -
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: java.nio.channels.ClosedChannelException
Description: Error during event handling: com.smartfoxserver.v2.exceptions.SFSRuntimeException: java.nio.channels.ClosedChannelException, Listener: { Ext: fantasyRivals, Type: JAVA, Lev: ZONE, { Zone: fantasyRivals }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSApi.disconnectUser(SFSApi.java:240)
com.smartfoxserver.v2.entities.SFSZone.applyForceLogin(SFSZone.java:1453)
com.smartfoxserver.v2.entities.SFSZone.login(SFSZone.java:1261)
com.smartfoxserver.v2.api.SFSApi.login(SFSApi.java:410)
com.smartfoxserver.v2.controllers.system.Login.execute(Login.java:136)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.executeEventCommand(SFSExtensionManager.java:1010)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:770)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:687)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:880)
com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:64)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


With isForceLogout true and userReconnectionSeconds : 5, the first client is disconnected, the second client is connected but the login does not complete as well, here is a log from the server:

Code: Select all

15:24:15,821 INFO  [SocketReader] core.SocketAcceptor     - Session created: { Id: 9, Type: DEFAULT, Logged: No, IP: 10.25.0.81:52941 } on Server port: 9933 <---> 52941
15:24:16,164 INFO  [pool-1-thread-7] entities.SFSZone     - User already logged in. Disconnecting previous instance : ( User Name: seb, Id: 4, Priv: 0, Sess: 10.25.0.81:52937 )
15:24:16,165 INFO  [SocketReader] sessions.DefaultSessionManager     - Session removed: { Id: 8, Type: DEFAULT, Logged: Yes, IP: 10.25.0.81:52937 }
15:24:16,166 INFO  [SocketReader] entities.SFSZone     - User: seb was disconnected.
15:24:16,167 INFO  [SocketReader] api.SFSApi     - User disconnected: ( User Name: seb, Id: 4, Priv: 0, Sess: 10.25.0.81:52937 )
15:24:16,168 INFO  [pool-1-thread-7] sessions.DefaultSessionManager     - Session removed: { Id: 8, Type: DEFAULT, Logged: Yes, IP: 10.25.0.81:52937 }
15:24:16,168 INFO  [pool-1-thread-7] entities.SFSZone     - User: seb was disconnected.
15:24:16,169 INFO  [pool-1-thread-7] api.SFSApi     - User disconnected: ( User Name: seb, Id: 4, Priv: 0, Sess: 10.25.0.81:52937 )
15:24:16,172 WARN  [pool-1-thread-7] managers.SFSExtensionManager     -
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: java.nio.channels.ClosedChannelException
Description: Error during event handling: com.smartfoxserver.v2.exceptions.SFSRuntimeException: java.nio.channels.ClosedChannelException, Listener: { Ext: fantasyRivals, Type: JAVA, Lev: ZONE, { Zone: fantasyRivals }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSApi.disconnectUser(SFSApi.java:240)
com.smartfoxserver.v2.entities.SFSZone.applyForceLogin(SFSZone.java:1453)
com.smartfoxserver.v2.entities.SFSZone.login(SFSZone.java:1261)
com.smartfoxserver.v2.api.SFSApi.login(SFSApi.java:410)
com.smartfoxserver.v2.controllers.system.Login.execute(Login.java:136)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.executeEventCommand(SFSExtensionManager.java:1010)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:770)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:687)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:880)
com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:64)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

15:24:17,207 INFO  [SocketReader] core.SocketAcceptor     - Session created: { Id: 10, Type: DEFAULT, Logged: No, IP: 10.25.0.81:52943 } on Server port: 9933 <---> 52943
15:24:17,222 INFO  [com.smartfoxserver.v2.controllers.SystemController-1] sessions.DefaultSessionManager     - Session removed: { Id: 10, Type: DEFAULT, Logged: No, IP: 10.25.0.81:52943 }
15:24:17,223 WARN  [com.smartfoxserver.v2.controllers.SystemController-1] controllers.SystemController     -
com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/10.25.0.3:9933 remote=/10.25.0.81:52943]
   com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:134)
   com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:376)
   com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
   com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:129)
   com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
   java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   java.lang.Thread.run(Unknown Source)


I did not try scenario B and C as A is already puzzling me.
I dont understand what I am doing wrong... can someone help me?

Thanks,

Sebastien
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 20 Jan 2012, 23:02

Hi.

Are you using SFS2x RC3?
And can you please give some more details about what procedure you're using to test this?
I created a simple client that connects and logs in with an username, launched 2 of these clients and the 1st one was successfully kicked when the 2nd one logged in, with no errors on the server side.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
Fraggle
Posts: 62
Joined: 02 Apr 2010, 06:41
Location: Paris, France

Postby Fraggle » 20 Jan 2012, 23:05

Hi!

Yes, I'm using RC3. As the title said, I'm using customLogin as well....
Basically:

Client connect with oauth key/secret, smartfox does an http call to our rest api (using oauth), get the user details, fill in the username (using out data) and that's it.
User avatar
Lapo
Site Admin
Posts: 21597
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Jan 2012, 11:37

Hi Fraggle,
I have tested your case A by adding a custom login extension to a test Zone.

ReconnectionTime == 0:
I am not able to reproduce/detect any errors, the old user gets properly disconnected first and the new one enters without problems. There might be something going on in your extension?

ReconnectionTime == 6:
I do see the same error, but it's not a problem, in fact you can ignore the issue and you should have noticed that the user does login.

The idea here is that the Reconnection system sees user LAPO disconnect and then LAPO opens a new socket and attempts a new connection.
HRC checks the sessionId and it doesn't match with the previous session, hence the message.

In theory the forceLogout feature should not be used with the HRC turned on for the reason I just explained, so you might want to turn it off. Otherwise if you decide to keep it active you will get the message but the system will work correctly, so no big deal.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: CustomLogin + HRC + isForceLogout

Postby wallis2xk » 19 Apr 2012, 15:14

I'm having the same issue and errors as in scenario A, in that the first user is disconnected correctly but the server throws this error

Code: Select all

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: java.nio.channels.ClosedChannelException
Description: Error during event handling: com.smartfoxserver.v2.exceptions.SFSRuntimeException: java.nio.channels.ClosedChannelException, Listener: { Ext: battleMonkeys, Type: JAVA, Lev: ZONE, { Zone: BattleMonkeys }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSApi.disconnectUser(SFSApi.java:240)
com.smartfoxserver.v2.entities.SFSZone.applyForceLogin(SFSZone.java:1453)
...


and the second user is left in limbo as his login doesn't seem to complete.

I do have custom login extension but both cases seems to proceed correctly through it, I'm not sure what I could be doing in there that is causing this?

Thanks
User avatar
Lapo
Site Admin
Posts: 21597
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: CustomLogin + HRC + isForceLogout

Postby Lapo » 21 Apr 2012, 12:16

Did you read my previous reply? The answer is valid for you too.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 16 guests