Smartfox sudden disconnection from game

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

JuliusBtesh
Posts: 58
Joined: 30 Sep 2014, 17:08

Smartfox sudden disconnection from game

Postby JuliusBtesh » 16 Feb 2015, 21:52

So I'm very close to completion with my project and I've been noticing for quite a while that sometimes I don't get requests back from Smartfox Server Scripts if I just leave my phone idle for a few minutes. I noticed that if I log out and then log back in, this will create a new connection and log me back into everything and then I can play the game.
So I tried debugging this issue and I watched the output of the game along with the output of the smartfox instance and nothing was coming out but after a few minutes (I checked after 5) my requests weren't going through to the server and coming back to the device. How can I get disconnected from smartfox without getting a connection lost error?
After a few more minutes of waiting, I finally received some of this stuff;

Code: Select all

[SFS - ERROR] TCPSocketLayer: General error reading data from socket: Read failure   at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
  at Sfs2X.Core.Sockets.TCPSocketLayer.Read () [0x00000] in <filename unknown>:0
[SFS - INFO] Reconnection attempt: 1 - time left:14.999683 sec.
OnConnectionRetry

[SFS - ERROR] TCPSocketLayer: Connection closed by the remote side
OnConnectionLost
Connection was lost, Reason: unknown
OnConnectionLost
Connection was lost, Reason: unknown


and Smartfox output was saying this ;

Code: Select all

20:46:24,250 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 5, Type: DEFAULT, Logged: No, IP: 24.193.11.96:50518 } on Server port: 9933 <---> 50518
20:46:24,252 WARN  [SFSWorker:Sys:1] v290.SystemReqController     - com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. Time expired for Session: { Id: 4, Type: DEFAULT, Logged: Yes, IP: 24.193.11.96:50489 }


What is going on here? Am I being disconnected for being idle? If yes, then why is it taking another few minutes before getting the signal that I was disconnected?

I have the session max idle time set to 60
I have the user max idle time set to 3600

Thanks in advanced!
User avatar
Lapo
Site Admin
Posts: 21723
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox sudden disconnection from game

Postby Lapo » 17 Feb 2015, 11:21

There is a reconnection time configured on the server side.
If you get disconnected the client will keep trying to reconnect for as long as you have configured the reconnection time on the server side.

Only after that time you will get a disconnection, unless of course you were able to reconnect.
Lapo
--
gotoAndPlay()
...addicted to flash games
JuliusBtesh
Posts: 58
Joined: 30 Sep 2014, 17:08

Re: Smartfox sudden disconnection from game

Postby JuliusBtesh » 17 Feb 2015, 21:09

If I get disconnected then I usually see my OnConnectionRetry and OnConnectionResume methods being called. This is something different. This is just happening silently without even indicating there is a disconnection. Is it a problem if I raise the session idle time to a few minutes? or more even?
User avatar
Lapo
Site Admin
Posts: 21723
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox sudden disconnection from game

Postby Lapo » 17 Feb 2015, 21:47

JuliusBtesh wrote:If I get disconnected then I usually see my OnConnectionRetry and OnConnectionResume methods being called. This is something different. This is just happening silently without even indicating there is a disconnection. Is it a problem if I raise the session idle time to a few minutes? or more even?

No, absolutely not. Normally you should allow a minimum of 2-3 minutes before disconnecting an idle user. Some allow longer times, depending on their application requisites.
Lapo

--

gotoAndPlay()

...addicted to flash games
JuliusBtesh
Posts: 58
Joined: 30 Sep 2014, 17:08

Re: Smartfox sudden disconnection from game

Postby JuliusBtesh » 18 Feb 2015, 23:07

I am currently testing this same issue. Im trying to find a fix for this but according to smartfox, smartfox.isConnected is still true even after this disconnection. To reiterate what is happening;

User is just idle, (in game/in menu, doesn't matter) no interaction between client/server and then when I try to trigger a request to smartfox after this "disconnection" happens. Nothing goes through to the server and I'm assuming I will need to recreate the smartfox instance on the client side in order to reconnect the user.

My problem is, being that smartfox thinks its connected (everything is still showing the user is connected. smartfox.isConnected, smartfox.myself, even the admin panel shows user is still there) I cant just say if (!smartfox.isConnected) try to reconnect.

How else can I go around this?
User avatar
Lapo
Site Admin
Posts: 21723
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox sudden disconnection from game

Postby Lapo » 19 Feb 2015, 10:15

Could you please provide more details?
What server version are you using? What C# API version?

What platform are you testing on? WebPlayer? Mobile? If so which OS and what type of connection (wifi / 3g)

Are you testing locally or with a remote server?

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
JuliusBtesh
Posts: 58
Joined: 30 Sep 2014, 17:08

Re: Smartfox sudden disconnection from game

Postby JuliusBtesh » 19 Feb 2015, 15:19

I have tested this with Android/iOS and in the Editor. All 3 have the same problem. I am using C# version 1.5.7 and Smartfox 2.9.2. I am using a remote server and I have tried 4g and wifi. This problem persists no matter what and always seems to occur after a few moments (under 5 minutes) of no client/server interaction.
Like I have stated above, everything pointing to the logged in user shows that the user is still there. The problem is that when the user tries to send out something to the server, the server never gets it so it never receives something back.
User avatar
Lapo
Site Admin
Posts: 21723
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Smartfox sudden disconnection from game

Postby Lapo » 19 Feb 2015, 17:17

Can we test this from remote?
You could send me via private message or email the address of your server and a Zone where I can connect.

That's all we need.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
JuliusBtesh
Posts: 58
Joined: 30 Sep 2014, 17:08

Re: Smartfox sudden disconnection from game

Postby JuliusBtesh » 20 Feb 2015, 03:37

I have sent you a pm

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 6 guests