Frequent disconnect on iOS devices

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Frequent disconnect on iOS devices

Postby clam61 » 12 Jul 2014, 19:48

The problem I have been having with the iOS API on my iPhone 7 is that I lose connection frequently. Definitely nothing to do with the idle time, because I send a ping quite often, and I have also seen a disconnect happen a few seconds after a successful connection.

The auto reconnect never seems to work and onConnectionLost occurs

What's odd is that I monitored the server log and at the time I do not see any message regarding a disconnect for that user


EDIT --------

I'm staring at the logs and right when I get a disconnect notification on my phone I see the following in the log:

12:15:38,721 INFO [SocketReader] sessions.DefaultSessionManager - Session created: { Id: 7, Type: DEFAULT, Logged: No, IP: 166.137.219.15:36103 } on Server port: 80 <---> 36103
SENDING TO -------> { Id: 7, Type: DEFAULT, Logged: No, IP: 166.137.219.15:36103 }
12:15:38,724 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=/216.73.102.76:80 remote=/166.137.219.15:36103]
com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)

12:15:38,789 INFO [SocketReader] sessions.DefaultSessionManager - Session removed: { Id: 7, Type: DEFAULT, Logged: No, IP: 166.137.219.15:36103 }


Every time I see something like the above. At first I ignored it because that is not my IP address, but after seeing it appear after every disconnect I think there is a connection.

The thing that changes is the IP. Another time it was ip 166.137.216.253. The thing is, neither of those are my IP address. :shock:
Last edited by clam61 on 16 Jul 2014, 23:47, edited 2 times in total.
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Frequent disconnect on iPhone 7

Postby clam61 » 12 Jul 2014, 20:20

This is very odd

From my iPad 1 (iOS 5.1) I also got the frequent disconnect but I do see the correct IP for my computer

Btw this is all on wifi and my Android device seems to be running ok with no disconnect.
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Frequent disconnect on iPhone 7

Postby clam61 » 14 Jul 2014, 22:35

Anybody have any issue with this?
User avatar
Lapo
Site Admin
Posts: 19602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Frequent disconnect on iPhone 7

Postby Lapo » 15 Jul 2014, 15:41

So you're saying you're loosing connection very often when using WiFi?
Is it like an office or home connection? Or a public WiFi?

Loosing connection via WiFi is usually not expected, unless there's a faint signal or the connection from your modem/router to the server is very poor.

It would also help to know what server and what API versions are in use.

Also what's the configured value of the "Reconnection Time" in your Zone?
Lapo
--
gotoAndPlay()
...addicted to flash games
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Frequent disconnect on iPhone 7

Postby clam61 » 15 Jul 2014, 21:32

Hi Lapo

Yes I am using home wifi, so the signal should be very strong.

With my Android device, this never happens. With my iOS devices (iPhone 7, iPad 1) this happens.

I am using the latest Objective C Api (downloaded a few days ago), and my reconnection timeframe set in my zone is 5 seconds
Last edited by clam61 on 16 Jul 2014, 04:07, edited 1 time in total.
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Frequent disconnect on iPhone 7

Postby clam61 » 16 Jul 2014, 03:49

i did some more testing.

it happens on a clean start of SFS2X, a clean start of my app client, after a disconnect, after a reconnection, bringing my app to the foreground... Any combination.

Also, it is not happening due to timeouts, because I see the pings on the server log every 4 minutes (set to 5 minute timeout), and i dont think there would be a HRC reconnection attempt if the user was kicked for idle reasons.

btw, on hte onConnectionLost method, the "reason" for the disconnect is "unknown"

here is the log for connecting

Code: Select all

15 Jul 2014 | 20:13:46,129 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 12, Type: DEFAULT, Logged: No, IP: 99.47.40.16:55176 } on Server port: 80 <---> 55176
15 Jul 2014 | 20:13:46,192 | INFO  | pool-1-thread-2 | v2.entities.SFSZone |     | User already logged in. Disconnecting previous instance : ( User Name: 64, Id: 6, Priv: 0, Sess: 99.47.40.16:55167 )
15 Jul 2014 | 20:13:46,193 | INFO  | pool-1-thread-2 | bitswarm.sessions.DefaultSessionManager |     | Session removed: { Id: 10, Type: DEFAULT, Logged: Yes, IP: 99.47.40.16:55167 }
15 Jul 2014 | 20:13:46,193 | INFO  | pool-1-thread-2 | v2.entities.SFSZone |     | User: 64 was disconnected.
15 Jul 2014 | 20:13:46,196 | INFO  | pool-1-thread-2 | v2.api.SFSApi |     | User disconnected: { Zone: ZombieBash }, ( User Name: 64, Id: 6, Priv: 0, Sess: 99.47.40.16:55167 ) , SessionLen: 62583, Type: IOS version: 7.0.4
15 Jul 2014 | 20:13:48,197 | INFO  | pool-2-thread-2 | v2.api.SFSApi |     | User login: { Zone: ZombieBash }, ( User Name: 64, Id: 7, Priv: 0, Sess: 99.47.40.16:55176 ) , Type: IOS version: 7.0.4
15 Jul 2014 | 20:13:48,391 | INFO  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.api.SFSBuddyApi |     | Buddy online state is already: true, ( User Name: 64, Id: 7, Priv: 0, Sess: 99.47.40.16:55176 )
15 Jul 2014 | 20:15:40,700 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 13, Type: DEFAULT, Logged: No, IP: 198.228.211.254:55455 } on Server port: 80 <---> 55455
15 Jul 2014 | 20:15:40,702 | WARN  | com.smartfoxserver.v2.controllers.SystemController-1 | 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=/216.73.102.76:80 remote=/198.228.211.254:55455]
        com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
        com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
        com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
        com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
        com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
        java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)


here is the disconnect part

Code: Select all

15 Jul 2014 | 20:15:40,700 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 13, Type: DEFAULT, Logged: No, IP: 198.228.211.254:55455 } on Server port: 80 <---> 55455
15 Jul 2014 | 20:15:40,702 | WARN  | com.smartfoxserver.v2.controllers.SystemController-1 | 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=/216.73.102.76:80 remote=/198.228.211.254:55455]
        com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
        com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
        com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
        com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
        com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
        java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)


here is another instance of the connect/disconnect which is a little bit simpler

Code: Select all

15 Jul 2014 | 20:12:43,614 | INFO  | pool-1-thread-3 | v2.api.SFSApi |     | User login: { Zone: XXX }, ( User Name: 64, Id: 6, Priv: 0, Sess: 99.47.40.16:55167 ) , Type: IOS version: 7.0.4
15 Jul 2014 | 20:12:43,754 | INFO  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.api.SFSBuddyApi |     | Buddy online state is already: true, ( User Name: 64, Id: 6, Priv: 0, Sess: 99.47.40.16:55167 )
15 Jul 2014 | 20:12:53,841 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 11, Type: DEFAULT, Logged: No, IP: 198.228.211.254:42920 } on Server port: 80 <---> 42920
15 Jul 2014 | 20:12:53,843 | WARN  | com.smartfoxserver.v2.controllers.SystemController-1 | 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=/216.73.102.76:80 remote=/198.228.211.254:42920]
        com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
        com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
        com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
        com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
        com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
        java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)
User avatar
Lapo
Site Admin
Posts: 19602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Frequent disconnect on iPhone 7

Postby Lapo » 16 Jul 2014, 08:16

clam61 wrote:Hi Lapo

Yes I am using home wifi, so the signal should be very strong.

With my Android device, this never happens. With my iOS devices (iPhone 7, iPad 1) this happens.

I am using the latest Objective C Api (downloaded a few days ago), and my reconnection timeframe set in my zone is 5 seconds

Try adding a few more seconds. E.g. 15-20 seconds and let me know if you're still seeing those reconnection errors.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 19602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Frequent disconnect on iPhone 7

Postby Lapo » 16 Jul 2014, 08:21

Another thing, you said you're testing with your home wifi but the server doesn't seem local. You're connecting to a remote server, correct?
If so are you sure your internet connection is not too busy or maybe it's experiencing slow downs at times?
Lapo

--

gotoAndPlay()

...addicted to flash games
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Frequent disconnect on iPhone 7

Postby clam61 » 16 Jul 2014, 22:29

Hi Lapo

The server is remote, but there are at most two users logged in. One is me via iOS and one is me via Android.

I increased the reconnection time to 15 seconds and still get onConnectionLost for iOS devices, but my Android devices never get disconnected at all.

Im thinking it could be a iOS client issue.

Here is a question. Why am I getting this message on the server log. Is this relevant?

Code: Select all

16 Jul 2014 | 15:11:03,425 | INFO  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.api.SFSBuddyApi |     | Buddy online state is already: true, ( User Name: 64, Id: 0, Priv: 0, Sess: 99.47.40.16:58113 ) 
User avatar
Lapo
Site Admin
Posts: 19602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Frequent disconnect on iPhone 7

Postby Lapo » 17 Jul 2014, 10:50

clam61 wrote:Hi Lapo

The server is remote, but there are at most two users logged in. One is me via iOS and one is me via Android.

This amount of people connected doesn't make much of a difference. I was pointing out that if your home connection towards the server isn't very good there will be problems. Of course if you run the test at the same time with an Android and iOS device and you get only disconnected on the latter the problem seems on the iOS device only.

But you should reproduce it at least 5-6 times in a row before jumping to conclusions.

I increased the reconnection time to 15 seconds and still get onConnectionLost for iOS devices, but my Android devices never get disconnected at all.
Im thinking it could be a iOS client issue.

Yes, but if it is then it's a low level issue. Unrelated with the API. The API code doesn't govern the connection stability. Only the OS does. (Unless the server is sending 15-20 messages/sec continuously to all clients).


Here is a question. Why am I getting this message on the server log. Is this relevant?

Code: Select all

16 Jul 2014 | 15:11:03,425 | INFO  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.api.SFSBuddyApi |     | Buddy online state is already: true, ( User Name: 64, Id: 0, Priv: 0, Sess: 99.47.40.16:58113 ) 

No, it's irrelevant to the connection issue.

This error is logged when a GoOnlineRequest(true) from client side is received but the "Online" state of the client is already set to that state.
Lapo

--

gotoAndPlay()

...addicted to flash games
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Frequent disconnect on iOS devices

Postby clam61 » 05 Aug 2014, 02:54

I installed the latest version of SmartFoxServer. Using the latest iOS SDK as well.

Still getting frequent disconnects. No one else is observing this problem?

Also with the new version of SFS, when I get the client connection retry event, I see this in the log at the same time. Kind of does not make sense. The exception says the reconnection attempt failed, but that is also when the client gets the event to start a reconnection attempt.

Of course after waiting a while, the onConnectionLost event triggers in the client

04 Aug 2014 | 18:57:02,098 | WARN | SFSWorker:Sys:3 | controllers.v290.SystemReqController | | com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. Time expired for Session: { Id: 109, Type: DEFAULT, Logged: Yes, IP: 99.47.40.16:52129 }
com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:154)
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(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
User avatar
Lapo
Site Admin
Posts: 19602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Frequent disconnect on iOS devices

Postby Lapo » 05 Aug 2014, 21:03

Have you tried connecting one or more web-based clients to the server?
If the same "frequent disconnection" problem happens for web clients too then you may have network problems on your hosting side. Otherwise it's very likely due to the nature of mobile connections.
Lapo

--

gotoAndPlay()

...addicted to flash games
clam61
Posts: 125
Joined: 12 Sep 2007, 02:00

Re: Frequent disconnect on iOS devices

Postby clam61 » 13 Aug 2014, 22:16

web clients as well as android clients have no issues.

just iOS
User avatar
Lapo
Site Admin
Posts: 19602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Frequent disconnect on iOS devices

Postby Lapo » 14 Aug 2014, 10:25

What platform did you use to build the iOS client. Native XCode + Object-C? Something else?

We don't have any reports of the iOS API being connection unstable, besides the normal issues caused by 3G networks. In your case, testing from WIFI there should be no problem at all.

Is your game/application sending lots of messages per second? E.g. like an action/realtime game?

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Zammy
Posts: 29
Joined: 05 Aug 2014, 16:37

Re: Frequent disconnect on iOS devices

Postby Zammy » 09 Dec 2014, 14:10

@Lapo, Why is this exception thrown? What does it mean? How to avoid it being thrown?

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 2 guests