Automatically disconnecting after 2 minutes of playing

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

Moderators: Lapo, Bax

Post Reply
JoseFranco
Posts: 10
Joined: 29 Jun 2010, 07:48
Location: Tenerife, Canary Islands

Automatically disconnecting after 2 minutes of playing

Post by JoseFranco »

Hello all,

I'm developing a small example using the known Islands Demo with this SFS2X server. I have the SFS server installed in my computer and running an instance of the game in another computer inside the same local network.

Well my problem is this one:
Everytime I connect to the game everything runs fine for about 2 minutes. After that, the client does not "feel" anything, but in the server console I get the following messages:

Code: Select all

01 feb 2011 17:07:38,981 INFO  [SocketReader] bitswarm.sessions.DefaultSessionManager     - Session removed: { Id: 5, Type:DEFAULT, Logged: Yes, IP: 192.168.10.103:1427 }
01 feb 2011 17:07:38,982 INFO  [SocketReader] v2.entities.SFSZone     - User: Cristo was disconnected.
01 feb 2011 17:07:38,983 INFO  [SocketReader] v2.api.SFSApi     - User disconnected: ( User Name: Cristo, Id: 1, Priv: 0, Sess: 192.168.10.103:1427 ) 
01 feb 2011 17:07:38,983 INFO  [pool-1-thread-1] Extensions     - {json}: User disconnected because: UNKNOWN 
01 feb 2011 17:07:38,984 INFO  [SocketReader] bitswarm.core.SocketReader     - Socket closed: java.nio.channels.SocketChannel[closed]
(The extension message is a small trace I wrote to check the reason why it disconnects from the server).
After those errors, I can't contact the server (I can't send any message). In the client log, I get this message just before the disconnection:

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 
If it is of any help I get a lot of these (a lot, a lot) before the previous message:

Code: Select all

Header of the buffer: Binary Size: 3
12 00 08                                        	...             

Header of the buffer: Binary Size: 3
12 00 03                                        	...             

Header of the buffer: Binary Size: 3
12 00 03                                        	...             

Header of the buffer: Binary Size: 3
12 00 08                                        	...     
I've been checking all kind of similar errors reported in the forums, changing the DLL, checking the security prefetch policy file, etc. but I have not found any solution.

I've noticed this error does not happen when using the editor, but just when using the webplayer.

Does anyone has any clue about what could be happening?
Thanks very much in advance,

José Franco.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Post by appels »

Idle timeout ? are you sending packets to the server when your connected ?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Post by ThomasLund »

Sounds definitely like idle timeout - which corresponds with the log entries.

Until the server boys implement a keep-alive ping, I've coded one myself for a project where I have a lot of inactivity.

Simply setup a "once every 20 seconds send a PM to myself" and that should fix it

/T
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

hi thomas. Im having some problems with the idle system. It doest matter if i set it to 1 or 999999, it will always disconnect the user after 30 seconds. Btw, i always restart the server after each change in the config. Does it have to do with the keep alive ping not being available?

Nvm, i forgot to set it in the zone configurator too.
Last edited by rjgtav on 03 Feb 2011, 19:29, edited 1 time in total.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
JoseFranco
Posts: 10
Joined: 29 Jun 2010, 07:48
Location: Tenerife, Canary Islands

Still with disconnection problem: more clues

Post by JoseFranco »

Thanks ThomasLund and appels for your answers.

I have tried that solution, set up a small script to send a private message to myself every 5 seconds. I tried with private messages, public messages and even extension messages, but still the problem is there.

Checking more stuff, I came to the conclussion that after a certain amount of sent packets, the user gets disconnected. Better explained, everytime my player moves, a "GenericMessage" appears on the server console, and after a certain amount of those GenericMessages, the user gets disconnected. Could it be because I'm sending too many packets to the server? Or a bad configuration maybe?

Anyway, I'm pasting two images that show the server monitor and the zone monitor at the time the user gets disconnected, maybe it can help to solve the riddle:

Image

Image

Thanks in advance!

EDIT: I've finished with another test. It gave me that after around 1220 "GenericMessages", the user got disconnected.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

It could be a problem with the idle user disconnector.
Can you please run a simple test changing the max user idle time to a short value such as 40-50 seconds?

Thank you
Lapo
--
gotoAndPlay()
...addicted to flash games
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Post by appels »

'GenericMessages' are chat messages so i'm not sure why you get so many when you move. You should only get these when someone sends a message.
JoseFranco
Posts: 10
Joined: 29 Jun 2010, 07:48
Location: Tenerife, Canary Islands

Post by JoseFranco »

Lapo, I've set the userMaxIdleTime to 50, and also the userMaxIdleTime on the Zone configurator, but the result is still the same.

appels, I get all those messages because I'm sending my position as an ObjectMessage to all users so they can draw my player on the exact position everytime I change it. I took it from the Island demo for the SFS 1.x and Unity 2.x.
Anyway, I just removed that Object Message request and now I don't get all those GenericMessages, but the same is still happening.

Hum... it puzzles me, I thought it was because of all those Generic Messages, but it seems to have another explanation.
JoseFranco
Posts: 10
Joined: 29 Jun 2010, 07:48
Location: Tenerife, Canary Islands

Disconnection problem: news

Post by JoseFranco »

Alright, my bad. I was in a rush yesterday and couldn't check the test results properly.
When removing the ObjectMessageRequest that generates all those GenericMessages, I don't get disconnected until the Idle Time expires.

I've change the sending packet script so the game sends only one packet when I want to, in order to check whether I get disconnected because of those GenericMessages or not. And the answer is YES, after that certain amount of GenericMessages I get disconnected, and the DisconnectionReason gets set to "UNKNOWN".
If I don't send any packet in 60 seconds (the MaxIdleTime set), I also get disconnnected but the DisconnectionReason gets set to "IDLE".

I'm thinking that maybe I'm not handling the server packets properly. Do I need to dispose read packets or do any kind of cleaning buffer or cleaning server operation during the execution of the game?
I'm thinking again about these lots of lines I got in the client webplayer log:

Code: Select all


Header of the buffer: Binary Size: 3 
12 00 08                                           ...              

Header of the buffer: Binary Size: 3 
12 00 03                                           ...              

Header of the buffer: Binary Size: 3 
12 00 03                                           ...              

Header of the buffer: Binary Size: 3 
12 00 08                                           ...      

Could it have something to do with all of this?

Thanks in advance!

EDIT: Forget all those Buffer lines, I don't get them anymore and the problem is still there. Also, it is appearing when running the game from the editor.
JoseFranco
Posts: 10
Joined: 29 Jun 2010, 07:48
Location: Tenerife, Canary Islands

Found it?

Post by JoseFranco »

Good news! Or so I think...

I was really confused when the error happened also when using the editor (because it didn't happen before), so I checked the connection configuration again.
Well, it seems that when using port 21 the user gets disconnected after all those packets sent. Just curiosity, why did it happen?
But, when I changed to port 9933, no disconnection at all.

I was using port 21 because the project I'm working on will use a server on a fragile location, so I needed one of the known ports. Again, curiosity, is there any other port I could use, beside 9933?
If not, I will talk with the network admin and ask him to open that port, but it could be interesting to use another one.

Thanks all for helping me with the issue!
Post Reply