Page 1 of 1

handling Session Reconnection failure

Posted: 08 Dec 2014, 18:54
by mephi
Hi Lapo,
I'm using sfs2x v. 2.9.0 and connection IOS clients to it.
I am not very sure if the post is for the IOS section or the server one...

When I put my app in the background, and then open it again - how should I manage the session reconnection?
Should I listen to any events and do anything specific, or should i let it to the smartfoxClient to handle the reconnection on its own?

Right now I try to reconnect to the server and re-create the smarfoxClient object as suggested in this topic
http://forums.smartfoxserver.com/viewtopic.php?t=12552

But I get this issue:
look below this line

Code: Select all

19:51:40,567 INFO  [SFSWorker:Ext:4] Extensions     - {ScavengerArenaExtension}: Skill played in [BotRoom7021] user [54831555d4c6fbedbbead85e] Power Punch
after it I put the app in the background and then bring it back.

Code: Select all

19:50:57,870 INFO  [SFSWorker:Sys:1] v2.SmartFoxServer     - SmartFoxServer 2X (2.9.0) READY!
19:50:59,585 INFO  [main] v3.SessionFilter     - BlueBox-2X Service (3.0.0) ready.
19:51:28,418 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 1, Type: DEFAULT, Logged: No, IP: 192.168.0.101:57303 } on Server port: 9933 <---> 57303
19:51:28,439 INFO  [SFSWorker:Ext:3] Extensions     - {ScavengerArenaExtension}: user login with name(gcID) = G:1067204144
19:51:28,449 INFO  [SFSWorker:Ext:3] api.SFSApi     - User login: { Zone: ScavengerArena }, ( User Name: 54831555d4c6fbedbbead85e, Id: 0, Priv: 0, Sess: 192.168.0.101:57303 ) , Type: IOS version: 8.1.1
19:51:28,454 INFO  [SFSWorker:Ext:4] Extensions     - {ScavengerArenaExtension}: User joins zone u = 54831555d4c6fbedbbead85e; rating = 1000
19:51:28,456 INFO  [SFSWorker:Ext:4] api.SFSApi     - Room joined: [ Room: MainLobby, Id: 0, Group: default, isGame: false ], { Zone: ScavengerArena }, ( User Name: 54831555d4c6fbedbbead85e, Id: 0, Priv: 0, Sess: 192.168.0.101:57303 ) , asSpect: false
19:51:37,429 INFO  [SFSWorker:Ext:1] managers.SFSRoomManager     - Room created: { Zone: ScavengerArena }, [ Room: BotRoom7021, Id: 4, Group: default, isGame: true ]
19:51:37,431 INFO  [SFSWorker:Ext:1] api.SFSApi     - Room joined: [ Room: BotRoom7021, Id: 4, Group: default, isGame: true ], { Zone: ScavengerArena }, ( User Name: 54831555d4c6fbedbbead85e, Id: 0, Priv: 0, Sess: 192.168.0.101:57303 ) , asSpect: false
19:51:40,567 INFO  [SFSWorker:Ext:4] Extensions     - {ScavengerArenaExtension}: Skill played in [BotRoom7021] user [54831555d4c6fbedbbead85e] Power Punch
19:51:51,523 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 2, Type: DEFAULT, Logged: No, IP: 192.168.0.101:57308 } on Server port: 9933 <---> 57308
19:51:51,531 INFO  [SFSWorker:Ext:2] Extensions     - {ScavengerArenaExtension}: user login with name(gcID) = G:1067204144
19:51:51,533 INFO  [SFSWorker:Ext:2] scala.DefLI     - User already logged in. Disconnecting previous instance : ( User Name: 54831555d4c6fbedbbead85e, Id: 0, Priv: 0, Sess: 192.168.0.101:57303 )
19:51:51,534 INFO  [SFSWorker:Ext:2] sessions.DefaultSessionManager     - Session removed: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 192.168.0.101:57303 }
19:51:51,535 INFO  [SFSWorker:Ext:2] managers.SFSRoomManager     - Room removed: { Zone: ScavengerArena }, [ Room: BotRoom7021, Id: 4, Group: default, isGame: true ], Duration: 14107
19:51:51,536 INFO  [SFSWorker:Ext:2] api.SFSApi     - User disconnected: { Zone: ScavengerArena }, ( User Name: 54831555d4c6fbedbbead85e, Id: 0, Priv: 0, Sess: 192.168.0.101:57303 ) , SessionLen: 23087, Type: IOS version: 8.1.1
19:51:52,633 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 3, Type: DEFAULT, Logged: No, IP: 192.168.0.101:57309 } on Server port: 9933 <---> 57309
SENDING TO -------> { Id: 3, Type: DEFAULT, Logged: No, IP: 192.168.0.101:57309 }
19:51:52,655 WARN  [SFSWorker:Sys:4] v290.SystemReqController     - com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/192.168.0.102:9933 remote=/192.168.0.101:57309]
	com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:146)
	com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
	com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
	com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:157)
	com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:114)
	com.smartfoxserver.bitswarm.io.protocols.AbstractProtocolCodec.dispatchRequestToController(AbstractProtocolCodec.java:39)
	com.smartfoxserver.v2.protocol.SFSProtocolCodec.dispatchRequest(SFSProtocolCodec.java:125)
	com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketRead(SFSProtocolCodec.java:90)
	com.smartfoxserver.v2.protocol.binary.BinaryIoHandler$1.run(BinaryIoHandler.java:525)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	java.lang.Thread.run(Thread.java:745)

19:51:52,666 INFO  [SocketReader] sessions.DefaultSessionManager     - Session removed: { Id: 3, Type: DEFAULT, Logged: No, IP: 192.168.0.101:57309 }

Re: handling Session Reconnection failure

Posted: 09 Dec 2014, 10:05
by Lapo
Hi,
good question. Depends on what happens when you put the APP in the background and also, I suspect, for how long.
What happens to the connection when the apps goes in the background? Do you get immediately a disconnection? Does it happen after a while? Never?

You can see that on the server side.

If the connection is "killed" while the app is background I am not sure if it can react and try to reconnect. If it doesn't the reconnection may not work, because the app may not come back to life soon enough.

Thanks

Re: handling Session Reconnection failure

Posted: 09 Dec 2014, 13:03
by mephi
I tried both scenarios.

1st - I put the app in the background for a short time (less than "userReconnectionSeconds" and "overrideMaxUserIdleTime"), and I get the same error which I already described.
2nd - I put it longer than this time settings. The session gets dropped, the user disconnected

Code: Select all

14:01:13,092 INFO  [Scheduler1-thread-1] sessions.DefaultSessionManager     - Session removed: { Id: 14, Type: DEFAULT, Logged: Yes, IP: 192.168.0.101:57752 }
14:01:13,094 INFO  [SFSWorker:Sys:4] api.SFSApi     - User disconnected: { Zone: whatever }, ( User Name: 54831555d4c6fbedbbead85e, Id: 7, Priv: 0, Sess: 192.168.0.101:57752 ) , SessionLen: 92654, Type: IOS version: 8.1.1
I see in the admin tool that there are no clients connected. Then When I put back the app and it gives the same error.

It seems I am having the same problem as this guy described:
http://forums.smartfoxserver.com/viewto ... 21&t=17280

I am not sure if I do something wrong or it is the client api. It seems it does not try to use the old session, but try to connect a new one, but the server expects the old session?
What do you think - might this be the case?

Thanks

Re: handling Session Reconnection failure

Posted: 09 Dec 2014, 14:53
by Lapo
For starters I don't understand what's going on in the first report you have posted.
  • There is a user logging in (source port 57303), name: G:1067204144.
    The user joins a couple of Rooms.

    ...< 10 seconds pause >...

    New user created (source port 57308), login with the same name as the prev. user --> G:1067204144
    Old user is kicked out

    Another new session is created (source port 57309) which then causes a reconnection error.
Is the background mode entered at the <10 second pause> mark? If so it seems that the application is completely restarted because a new connection is made and a new login, causing a previous user to be kicked out.

Also can you specify which iOS API version are you using?

Re: handling Session Reconnection failure

Posted: 11 Dec 2014, 15:47
by mephi
Hi Lapo,

I’ve worked a while at the problem. Cleared out some issues on our side.
Now the problem happens only in the second case. Meaning, if I put the APP back within the <10 sec pause> everything is fine. No problem there. But if the user gets disconnected (after the 10sec), and I get back to it, it throws the same SessionReconnectionException.

Now I do not expect the reconnection to work after the timeout has been reached. Of course the user has to re-connect and login again. But I don’t think this is normal, and the state in the client gets damaged by it.

I am using:
[SFS - INFO]SFS2X API version: 1.3.7

I did an experiment with your IOS examples to check if I can reproduce it with them. And yes, it’s there. I used the Connector example and changed only SFS2X_iOS_Examples/Connector/Connector/ViewController.m file. I am attaching it here. (below I describe the changes one by one)

I run SmartFoxServer 2X (2.9.0).
You can change the ViewController.m with this one.
In the BasicExamples Zone I’ve changed only the timeouts to be 10/30 like this:
<userReconnectionSeconds>10</userReconnectionSeconds>
<overrideMaxUserIdleTime>30</overrideMaxUserIdleTime>

Then. I run the app. It auto connects. The server sees the user. Everything is fine.
I put it on the background. Wait for the server to tell it disconnects the client.
Then put the app back active and the server gives the error.

Code: Select all

15:45:40,973 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 5, Type: DEFAULT, Logged: No, IP: 192.168.1.113:50013 } on Server port: 9933 <---> 50013
15:45:40,987 INFO  [SFSWorker:Sys:3] api.SFSApi     - User login: { Zone: BasicExamples }, ( User Name: testme, Id: 4, Priv: 0, Sess: 192.168.1.113:50013 ) , Type: IOS version: 8.1.1
15:46:04,538 INFO  [Scheduler1-thread-1] sessions.DefaultSessionManager     - Session removed: { Id: 5, Type: DEFAULT, Logged: Yes, IP: 192.168.1.113:50013 }
15:46:04,539 INFO  [SFSWorker:Sys:4] api.SFSApi     - User disconnected: { Zone: BasicExamples }, ( User Name: testme, Id: 4, Priv: 0, Sess: 192.168.1.113:50013 ) , SessionLen: 23552, Type: IOS version: 8.1.1
15:46:15,252 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 6, Type: DEFAULT, Logged: No, IP: 192.168.1.113:50021 } on Server port: 9933 <---> 50021
SENDING TO -------> { Id: 6, Type: DEFAULT, Logged: No, IP: 192.168.1.113:50021 }
15:46:15,276 INFO  [SocketReader] sessions.DefaultSessionManager     - Session removed: { Id: 6, Type: DEFAULT, Logged: No, IP: 192.168.1.113:50021 }
15:46:15,278 WARN  [SFSWorker:Sys:3] v290.SystemReqController     - com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/192.168.1.188:9933 remote=/192.168.1.113:50021]
	com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:146)
	com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
	com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
	com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:157)
	com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:114)
	com.smartfoxserver.bitswarm.io.protocols.AbstractProtocolCodec.dispatchRequestToController(AbstractProtocolCodec.java:39)
	com.smartfoxserver.v2.protocol.SFSProtocolCodec.dispatchRequest(SFSProtocolCodec.java:125)
	com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketRead(SFSProtocolCodec.java:90)
	com.smartfoxserver.v2.protocol.binary.BinaryIoHandler$1.run(BinaryIoHandler.java:525)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	java.lang.Thread.run(Thread.java:745)

The changes were with the idea to make it auto-reconnect and are the following lines:

Code: Select all


- (void)viewDidLoad
{
    [super viewDidLoad];
	smartFox = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:YES delegate:self];
    smartFox.logger.loggingLevel = LogLevel_DEBUG;
    
	[smartFox loadConfig:@"config.xml" connectOnSuccess:YES]; // changed line
}

Code: Select all

/**
 * Log in to the zone configured in the config.xml
 */
- (IBAction)login:(id)sender
{
    [self doLogin];  // changed line
}

// added new method to be used again
-(void) doLogin {
    [smartFox send:[LoginRequest requestWithUserName:@"testme" password:@"" zoneName:nil params:nil]];  // changed line to add some username
    loginBtn.enabled = NO;
}

Code: Select all

/**
 * Connection Events
 */
- (void)onConnection:(SFSEvent *)evt
{
	NSArray *keys = [evt.params allKeys];
	
	for (NSString *key in keys) {
		NSLog(@"%@: %@", key, [evt.params objectForKey:key]);
	}
    
	if ([[evt.params objectForKey:@"success"] boolValue])
	{
        [self trace:@"You are now connected to SFS2X"];
		connectBtn.enabled = NO;
        disconnectBtn.enabled = YES;
        loginBtn.enabled = YES;
        [self doLogin];  // added line
	}
	else
	{
		[self trace:[NSString stringWithFormat:@"Connection error: %@.", [evt.params objectForKey:@"error"]]];
        connectBtn.enabled = YES;
	}
}

Code: Select all

- (void)onConnectionLost:(SFSEvent *)evt
{
    [self trace:@"You have been disconnected from SFS2X"];
    connectBtn.enabled = YES;
    disconnectBtn.enabled = NO;
    loginBtn.enabled = NO;
    logoutBtn.enabled = NO;

    [smartFox connect]; // added line
    connectBtn.enabled = NO; // added line

}


I saw IOS examples are old, with an old api. I can conduct an experiment with updated API, but I am sure I will recreate it again.

Here is the client log too:

Code: Select all

2014-12-11 15:45:41.327 Connector[339:33135] [SFS - INFO]SFS2X API version: 1.2.1
2014-12-11 15:45:41.686 Connector[339:33135] [SFS - INFO]sending handshake request: isReconnection : NO
2014-12-11 15:45:41.687 Connector[339:33135] [SFS - INFO]WRITE - Creating a new buffer
2014-12-11 15:45:41.688 Connector[339:33135] [SFS - INFO]Data Write: Binary Size: 61 
80 00 3a 12 00 03 00 01 63 02 00 00 01 61 03 00 	..:.....c....a..
00 00 01 70 12 00 02 00 03 61 70 69 08 00 05 31 	...p.....api...1
2e 32 2e 31 00 02 63 6c 08 00 12 49 4f 53 20 76 	.2.1..cl...IOS.v
65 72 73 69 6f 6e 3a 20 38 2e 31 2e 31          	ersion:.8.1.1   
2014-12-11 15:45:41.689 Connector[339:33135] [SFS - INFO]WRITE - Written directly to outStream len:61
2014-12-11 15:45:41.694 Connector[339:33135] [SFS - INFO]Data Read: Binary Size: 80 
80 00 4d 12 00 03 00 01 61 03 00 00 00 01 63 02 	..M.....a.....c.
00 00 01 70 12 00 03 00 02 74 6b 08 00 20 63 65 	...p.....tk...ce
37 31 62 34 36 65 33 38 30 65 35 31 32 38 65 66 	71b46e380e5128ef
61 63 34 36 34 64 36 33 63 31 32 30 32 36 00 02 	ac464d63c12026..
63 74 04 00 00 04 00 00 02 6d 73 04 00 0f 42 40 	ct.......ms...B@
2014-12-11 15:45:41.695 Connector[339:33135] [SFS - DEBUG]Handling New Packet
2014-12-11 15:45:41.695 Connector[339:33135] [SFS - DEBUG]Handling Header Size. Size: 79 (small)
2014-12-11 15:45:41.695 Connector[339:33135] [SFS - DEBUG]Handling Data: 77, previous state: 0 / 77
2014-12-11 15:45:41.695 Connector[339:33135] [SFS - DEBUG]<<< Packet Complete >>>
2014-12-11 15:45:41.696 Connector[339:33135] [SFS - INFO]Handling Message: Handshake: { Message id: 0 }
{Dump: }

	(int) ms: 1000000
	(utf_string) tk: ce71b46e380e5128efac464d63c12026
	(int) ct: 1024
2014-12-11 15:45:41.696 Connector[339:33135] success: 1
2014-12-11 15:45:41.698 Connector[339:33135] [SFS - INFO]WRITE - Written directly to outStream len:63
2014-12-11 15:45:41.699 Connector[339:33135] [SFS - INFO]Data Write: Binary Size: 63 
80 00 3c 12 00 03 00 01 63 02 00 00 01 61 03 00 	..<.....c....a..
01 00 01 70 12 00 03 00 02 70 77 08 00 00 00 02 	...p.....pw.....
7a 6e 08 00 0d 42 61 73 69 63 45 78 61 6d 70 6c 	zn...BasicExampl
65 73 00 02 75 6e 08 00 06 74 65 73 74 6d 65    	es..un...testme 
2014-12-11 15:45:41.709 Connector[339:33135] [SFS - INFO]Data Read: Binary Size: 131 
80 00 80 12 00 03 00 01 61 03 00 01 00 01 63 02 	........a.....c.
00 00 01 70 12 00 06 00 02 72 6c 11 00 01 11 00 	...p.....rl.....
09 04 00 00 00 00 08 00 09 54 68 65 20 4c 6f 62 	.........The.Lob
62 79 08 00 07 64 65 66 61 75 6c 74 01 00 01 00 	by...default....
01 00 03 00 00 03 00 96 11 00 00 00 02 7a 6e 08 	.............zn.
00 0d 42 61 73 69 63 45 78 61 6d 70 6c 65 73 00 	..BasicExamples.
02 72 73 03 00 0a 00 02 75 6e 08 00 06 74 65 73 	.rs.....un...tes
74 6d 65 00 02 69 64 04 00 00 00 04 00 02 70 69 	tme..id.......pi
03 00 00                                        	...             
2014-12-11 15:45:41.709 Connector[339:33135] [SFS - DEBUG]Handling New Packet
2014-12-11 15:45:41.709 Connector[339:33135] [SFS - DEBUG]Handling Header Size. Size: 130 (small)
2014-12-11 15:45:41.710 Connector[339:33135] [SFS - DEBUG]Handling Data: 128, previous state: 0 / 128
2014-12-11 15:45:41.710 Connector[339:33135] [SFS - DEBUG]<<< Packet Complete >>>
2014-12-11 15:45:41.712 Connector[339:33135] [SFS - INFO]Handling Message: Login: { Message id: 1 }
{Dump: }

	(short) rs: 10
	(sfs_array) rl: 
		(sfs_array)
			(int)0
			(utf_string)The Lobby
			(utf_string)default
			(bool)0
			(bool)0
			(bool)0
			(short)0
			(short)150
			(sfs_array)
				
			
		
	
	(utf_string) zn: BasicExamples
	(utf_string) un: testme
	(int) id: 4
	(short) pi: 0
2014-12-11 15:46:14.779 Connector[339:33135] [SFS - INFO]Reconnection attempt: 10 sec.
2014-12-11 15:46:15.968 Connector[339:33135] [SFS - INFO]sending handshake request: isReconnection : YES
2014-12-11 15:46:15.969 Connector[339:33135] [SFS - INFO]WRITE - Creating a new buffer
2014-12-11 15:46:15.970 Connector[339:33135] [SFS - INFO]Data Write: Binary Size: 100 
80 00 61 12 00 03 00 01 63 02 00 00 01 61 03 00 	..a.....c....a..
00 00 01 70 12 00 03 00 03 61 70 69 08 00 05 31 	...p.....api...1
2e 32 2e 31 00 02 63 6c 08 00 12 49 4f 53 20 76 	.2.1..cl...IOS.v
65 72 73 69 6f 6e 3a 20 38 2e 31 2e 31 00 02 72 	ersion:.8.1.1..r
74 08 00 20 63 65 37 31 62 34 36 65 33 38 30 65 	t...ce71b46e380e
35 31 32 38 65 66 61 63 34 36 34 64 36 33 63 31 	5128efac464d63c1
32 30 32 36                                     	2026            
2014-12-11 15:46:15.971 Connector[339:33135] [SFS - INFO]WRITE - Written directly to outStream len:100
2014-12-11 15:46:15.989 Connector[339:33135] [SFS - INFO]Data Read: Binary Size: 23 
80 00 14 12 00 03 00 01 61 03 03 ee 00 01 63 02 	........a.....c.
00 00 01 70 12 00 00                            	...p...         
2014-12-11 15:46:15.990 Connector[339:33135] [SFS - DEBUG]Handling New Packet
2014-12-11 15:46:15.990 Connector[339:33135] [SFS - DEBUG]Handling Header Size. Size: 22 (small)
2014-12-11 15:46:15.990 Connector[339:33135] [SFS - DEBUG]Handling Data: 20, previous state: 0 / 20
2014-12-11 15:46:15.990 Connector[339:33135] [SFS - DEBUG]<<< Packet Complete >>>
2014-12-11 15:46:15.991 Connector[339:33135] [SFS - INFO]Handling Message: ReconnectionFailure: { Message id: 1006 }
{Dump: }

	
2014-12-11 15:46:15.994 Connector[339:33135] [SFS - WARN]Already connected!
Tell me if you cannot reproduce it, or you need more info.
Thanks!

Re: handling Session Reconnection failure

Posted: 11 Dec 2014, 16:02
by mephi
Just tried with 1.3.7 api on the client with the Connector example.
It gets the same server error.

Re: handling Session Reconnection failure

Posted: 12 Dec 2014, 08:44
by mephi
I just realised I forgot to attach the file from the Connector example :)
So here it is now.

Re: handling Session Reconnection failure

Posted: 12 Dec 2014, 09:31
by Lapo
Thanks, we'll take a look asap.

Re: handling Session Reconnection failure

Posted: 12 Dec 2014, 11:05
by Lapo
I tested the scenario using our "Connector example" from the Objective-C Example package.
Using the iPhone 6 simulator with iOS 8.1 the problem can't be replicated. The disconnection is handled correctly.

Maybe this is different with a device because the simulator uses the TCP stack of OSX. I don't have a device at hand to test on, at the moment.

I am also not sure what the problem really is, in your scenario. You are using an extremely low Idle Timer = 30 sec. We would normally don't recommend that. 5 minutes is usually a pretty low value. Typically you can allow a user to be idle for 10-15 minutes without any side effects, especially for mobile devices where users can be interrupted by many different things (phone calls, changes of location etc...)

In your case it looks like for some reason the client is only detecting the disconnection when waking up, but it was not able to parse the message that provided the cause of the disconnection. Because of this it thinks that it must have been disconnected abruptly and it attempts to reconnect. The server doesn't expect a reconnection from the client and therefore logs an error.

All this in actuality causes no harm.
From the client side you can simply restart the connection by creating a new SmartFox2XClient object, after having to deallocated the previous connection object.

Cheers

Re: handling Session Reconnection failure

Posted: 12 Dec 2014, 15:03
by mephi
Yes, on the IOS simulator it is not reproducable.
Try to test it on a device, you will see it then.

Thank you for the recommendation for the idle times. I will get them higher as you suggested. But I am using this values to reproduce the bug easier, otherwise you have to wait a lot...

You say that his server exception is no harm? Alright, although it seems there is something wrong going on...
Then if I understand you well, you advice to reconnect on such occasion like this:

Code: Select all

-(void) initSmartFox {
    smartFox = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:YES delegate:self];
    [smartFox loadConfig:@"config.xml" connectOnSuccess:YES];
}

- (void)onConnectionLost:(SFSEvent *)evt
{
    NSLog(@"onConnectionLost You have been disconnected from SFS2X"); 
    smartFox = NULL;
    [self initSmartFox];
}
Is this ok?

Re: handling Session Reconnection failure

Posted: 12 Dec 2014, 15:06
by Lapo
Yes, the exception on the server side causes absolutely no harm.
It's just a sign of the misunderstanding between client and server, meaning that the client did not understand that it was disconnected due to "being idle".

As regards your code snippet, yes that is what I was meaning.

Cheers

Re: handling Session Reconnection failure

Posted: 12 Dec 2014, 15:34
by mephi
Thanks for the support and the fast answers Lapo!
Cheers!