Page 1 of 1

Automatically disconnecting after 2 minutes of playing

Posted: 01 Feb 2011, 16:11
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.

Posted: 01 Feb 2011, 18:12
by appels
Idle timeout ? are you sending packets to the server when your connected ?

Posted: 02 Feb 2011, 06:48
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

Posted: 02 Feb 2011, 08:38
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.

Still with disconnection problem: more clues

Posted: 03 Feb 2011, 15:21
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.

Posted: 03 Feb 2011, 15:54
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

Posted: 03 Feb 2011, 15:55
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.

Posted: 03 Feb 2011, 16:26
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.

Disconnection problem: news

Posted: 04 Feb 2011, 07:29
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.

Found it?

Posted: 04 Feb 2011, 08:08
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!