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