A not so silent reconnection manager

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

Moderators: Lapo, Bax

ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

A not so silent reconnection manager

Postby ethereal » 18 Jan 2011, 23:04

Hi,

When a user trys to reconnect, i get this error.
No idea where i should look

Server version 1b
Client AS3 same.

Any help would be appreciated.



Code: Select all

19 jan 2011 01:15:31,257 WARN  [com.smartfoxserver.v2.controllers.SystemController-2] v2.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=/<IPADDRESS> remote=/<IPADDRESS>:49367]
   com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:134)
   com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:370)
   com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
   com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:127)
   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)
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 19 Jan 2011, 07:29

The error indicates that a client is attempting a reconnection but the server was not expecting it. Maybe the client reconnected too late. Try setting the reconnection time between 5 and 10 seconds.
Lapo
--
gotoAndPlay()
...addicted to flash games
ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

Postby ethereal » 19 Jan 2011, 17:24

HI,

It was on 90 seconds, should be enough.
Changed it to 7 seconds.

Looks the session is lost somehow. still no luck :(
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Jan 2011, 08:42

Can you explain how do you conduct this test?
Lapo

--

gotoAndPlay()

...addicted to flash games
ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

Postby ethereal » 21 Jan 2011, 00:27

I don't do anything special.

logging in with custom extension.

But there is another one.
If i login client side, i get this

Code: Select all

21 jan 2011 02:42:44,603 INFO  [SocketReader] bitswarm.core.SocketAcceptor     - Session created: { Id: 1, Type:DEFAULT, Logged: No, IP: <IP>:2298 } on Server port: 9933 <---> 2298
21 jan 2011 02:42:44,619 INFO  [SocketReader] bitswarm.sessions.DefaultSessionManager     - Session removed: { Id: 1, Type:DEFAULT, Logged: No, IP: <IP>:2298 }
21 jan 2011 02:42:44,650 INFO  [SocketReader] bitswarm.core.SocketAcceptor     - Session created: { Id: 2, Type:DEFAULT, Logged: No, IP: <IP>:2299 } on Server port: 9933 <---> 2299
21 jan 2011 02:42:44,681 INFO  [com.smartfoxserver.v2.controllers.SystemController-1] v2.controllers.SystemController     - {IN}: Handshake
21 jan 2011 02:42:44,744 INFO  [com.smartfoxserver.v2.controllers.SystemController-2] v2.controllers.SystemController     - {IN}: Login
21 jan 2011 02:42:44,822 INFO  [pool-1-thread-2] v2.api.SFSApi     - Login in, { Zone: SimpleChat }, ( User Name: test, Id: 0, Priv: 1, Sess: 94.209.117.173:2299 )
21 jan 2011 02:42:44,884 INFO  [com.smartfoxserver.v2.controllers.SystemController-1] v2.controllers.SystemController     - {IN}: JoinRoom


Looks fine to me.
then a logout, that gives me this

Code: Select all

02:45:30,916 INFO  [com.smartfoxserver.v2.controllers.SystemController-2] contro
llers.SystemController     - {IN}: Logout
02:45:30,931 INFO  [com.smartfoxserver.v2.controllers.SystemController-2] entiti
es.SFSZone     - User: test was disconnected.
02:45:30,931 INFO  [com.smartfoxserver.v2.controllers.SystemController-2] api.SF
SApi     - User logout: ( User Name: test, Id: 0, Priv: 1, Sess: <IP>:
2299 )


Looks okee too, but the client is still connected sfsi.sConnected returns true.
The server log is telling it is disconnected.

Now i close my browser tab with the sweet close button.
That gives me this.

Code: Select all

02:47:49,244 WARN  [SocketReader] core.SocketReader     - Problems in SocketRead
er main loop: com.smartfoxserver.v2.exceptions.SFSRuntimeException: -Unexpected-
 Cannot find any User for Session: { Id: 2, Type:DEFAULT, Logged: Yes, IP: <IP>:2299 }, Thread: Thread[SocketReader,5,main]
02:47:49,244 WARN  [SocketReader] core.SocketReader     -
com.smartfoxserver.v2.exceptions.SFSRuntimeException: -Unexpected- Cannot find a
ny User for Session: { Id: 2, Type:DEFAULT, Logged: Yes, IP: <IP>:2299
 }
        com.smartfoxserver.v2.SmartFoxServer.onSessionReconnectionTry(SmartFoxSe
rver.java:753)
        com.smartfoxserver.v2.SmartFoxServer.access$3(SmartFoxServer.java:748)
        com.smartfoxserver.v2.SmartFoxServer$BitSwarmEventListener.handleEvent(S
martFoxServer.java:809)
        com.smartfoxserver.bitswarm.service.BaseCoreService.dispatchEvent(BaseCo
reService.java:110)
        com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.dispatchSessi
onReconnectionTryEvent(DefaultSessionManager.java:752)
        com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.onSocketDisco
nnected(DefaultSessionManager.java:343)
        com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.onSocketDisco
nnected(DefaultSessionManager.java:329)
        com.smartfoxserver.bitswarm.core.SocketReader.closeTcpConnection(SocketR
eader.java:350)
        com.smartfoxserver.bitswarm.core.SocketReader.readTcpData(SocketReader.j
ava:319)
        com.smartfoxserver.bitswarm.core.SocketReader.readIncomingSocketData(Soc
ketReader.java:229)
        com.smartfoxserver.bitswarm.core.SocketReader.run(SocketReader.java:173)

        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)

02:48:09,697 INFO  [Scheduler1-thread-1] sessions.DefaultSessionManager     - Se
ssion removed: { Id: 2, Type:DEFAULT, Logged: Yes, IP: <IP>:2299 }


That doesnt look right.
There is no extension involved here except the login extension!!
what is nothing more then a login with a database as password/username base.
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Jan 2011, 12:56

I don't understand.
I need you to walk me through a series of steps.
Like:
1. Connect
2. Login.
3. Join...
... bla ...
... bla ...

and indicate at which point what kind of problems do you get.

BTW:
In the last comment you said you closed the browser. If you do that you cannot really expect that the reconnection will work? Right? :)
Lapo

--

gotoAndPlay()

...addicted to flash games
ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

Postby ethereal » 21 Jan 2011, 16:25

Lapo wrote:I don't understand.
I need you to walk me through a series of steps.
Like:
1. Connect
2. Login.
3. Join...
... bla ...
... bla ...

and indicate at which point what kind of problems do you get.

BTW:
In the last comment you said you closed the browser. If you do that you cannot really expect that the reconnection will work? Right? :)


First off all,
should i see a error like i showed before when someone closes his browser after a logout?
Looks scary. the reconnection shouldn't kick in att all The user is logged out!!


Okay, here we go :(

1.
Connect from as3 client and send info to server login_handler



Code: Select all

 ISFSObject userData = executeQueryreg.getSFSObject(0);
 ISFSObject responseObj = (ISFSObject)

event.getParameter(SFSEventParam.LOGIN_OUT_DATA);
 userData = cleanUserData((SFSObject) userData);

 session.setProperty("userData", userData);
 session.setProperty("$permission", DefaultPermissionProfile.STANDARD);
 responseObj.putSFSObject("userData", userData);


And we come to the LoginZoneEventhandler, and put in some user vars.
Send it to the client, and send The buddylist right after it, that works like a charme to me.

Code: Select all

   public void handleServerEvent(ISFSEvent isfse) throws SFSException
    {

ISFSApi smartfox = SmartFoxServer.getInstance().getAPIManager().getSFSApi();
User user = (User) isfse.getParameter(SFSEventParam.USER);
ISFSObject obj = (ISFSObject) user.getSession().getProperty("userData");

     List<UserVariable> vars = new ArrayList<UserVariable>();
       
        vars.add(new SFSUserVariable("rat", obj.getDouble("<SOMETHING>")));
        vars.add(new SFSUserVariable("rd", obj.getDouble("<SOMETHING>"), true));
        vars.add(new SFSUserVariable("rv", obj.getDouble("<SOMETHING>"), true));
        smartfox.setUserVariables(user, vars);
        try {
            SmartFoxServer.getInstance().getAPIManager().getBuddyApi().initBuddyList(user, true);
        } catch (IOException ex) {
            Logger.getLogger(LoginZoneEventHandler.class.getName()).log(Level.SEVERE, null, ex);
        }

    }


And now just logout from the client with

sfs.send(new LogoutRequest());

And close the browser.


Couldn't find any session, and throws a error.
Same happens when someone tries to reconnect.

i spotted a sfs.handleLogout() Couldnt find anything in the docs, is it internal?
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 25 Jan 2011, 16:56

First off all,
should i see a error like i showed before when someone closes his browser after a logout?
Looks scary. the reconnection shouldn't kick in att all The user is logged out!!

No actually it isn't. I was able to reproduce it when the reconnection system is turned on and a logout is performed and then the app is closed :) Not an easy scenario to imagine, but definitely can be reproduced.
I filed the error in the bug system. We'll soon take a look
Lapo

--

gotoAndPlay()

...addicted to flash games
ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

Postby ethereal » 28 Jan 2011, 08:10

Lapo wrote:No actually it isn't. I was able to reproduce it when the reconnection system is turned on and a logout is performed and then the app is closed :) Not an easy scenario to imagine, but definitely can be reproduced.
I filed the error in the bug system. We'll soon take a look


Well, infact, almost all my users use this scenario.

I found another one.
If you do all the before with the buddylist on the client, BUT not close the browser.
The server still updates the logged out clients buddylist, and throws a error on the client screens.
And sometimes crashes the whole flash player.
Killing plugin-container is the only way to get the client free again.


Hope it helps you guys a bit, SFS is a sweet product.
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 28 Jan 2011, 08:24

Well, infact, almost all my users use this scenario.

Can you explain why?
Also the exception does not break anything as far as I can see.
If a client has just logged out and it is disconnected the reconnection system will not work. This is because the HRC works only when you are logged in a Zone. If you are outside of any Zones your privilege level is super low and no HRC is available.

In the end I don't think this will be filed as a bug, but certainly we need to get rid of the exception.

Finally I am not sure why you should be disconnected exactly when after a logout. What happens in your application?

Thanks for reporting the other case. I will take a look and see if it's reproducible.
Lapo

--

gotoAndPlay()

...addicted to flash games
ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

Postby ethereal » 28 Jan 2011, 09:27

Lapo wrote:
Well, infact, almost all my users use this scenario.

Can you explain why?
Also the exception does not break anything as far as I can see.
If a client has just logged out and it is disconnected the reconnection system will not work. This is because the HRC works only when you are logged in a Zone. If you are outside of any Zones your privilege level is super low and no HRC is available.

In the end I don't think this will be filed as a bug, but certainly we need to get rid of the exception.

Finally I am not sure why you should be disconnected exactly when after a logout. What happens in your application?

Thanks for reporting the other case. I will take a look and see if it's reproducible.


Well i think i have some nice users, they play a game (Turnbased) and when they leave, they just push the logout button, and closing the browser afterwards.

It doesnt brake anything as far as i can see, but it looks pretty scary in the logs, and it certainly doesnt looks nice in a terminal window :(

I think the other way around, why should i be connected when i have logged out?
You should check IsConnected anyway before send some login info.
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

Postby ethereal » 31 Jan 2011, 11:13

Hi Lapo

Sorry to say, but looked a bit further, it does brake the whole reconnection system.

No reconnection is made correct after the named scenarion, they all fail.
no session is correct.
no reconnection events on the server side.

SFSEventType.USER_RECONNECTION_TRY
SFSEventType.USER_RECONNECTION_SUCCESS

its going strait to
SFSEventType.USER_DISCONNECT

And throws a exception on the console.
And that are users that are playing in a game and just have a little hickup in there connections, (First post)
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Feb 2011, 14:00

I am not able to reproduce this scenario.
I intentionally caused the error you have mentioned with one user. Then I continued by adding more users and using the kill() function to simulate an unexpected disconnection and everything worked as expected.
Lapo

--

gotoAndPlay()

...addicted to flash games
ethereal
Posts: 54
Joined: 02 Nov 2005, 18:26
Location: netherlands

Postby ethereal » 08 Feb 2011, 22:20

Lapo wrote:I am not able to reproduce this scenario.
I intentionally caused the error you have mentioned with one user. Then I continued by adding more users and using the kill() function to simulate an unexpected disconnection and everything worked as expected.



tried your scenario with the Kill() Function, and indeed no error.
When is close the browser without, the error pops up again.

When i pull the cable out off the client machine, again a error.
Flex, Smartfoxserver, red5. and Linux Why does microsoft still exist?
nino
Posts: 13
Joined: 13 Aug 2014, 11:16

Re: A not so silent reconnection manager

Postby nino » 18 Aug 2014, 11:04

I changed "user reconnection time frame" to 5 seconds, user maximum idle time to 150. I have reconnect successfull (this ok) but client not fire SFSEvent.CONNECTION_RESUME. I need "SFSEvent.CONNECTION_RESUME" event to refresh my game board :(

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 100 guests