Connection stops at handshake when trying to connect

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

Moderators: Lapo, Bax

Post Reply
GoaKoala
Posts: 5
Joined: 11 Mar 2011, 17:10

Connection stops at handshake when trying to connect

Post by GoaKoala »

Hello all;

I am writing a c# console application using unity api. When i try to connect to the smartfox, system hangs up at the handshake.

Log at the smartfox;
11 Mar 2011 17:57:31,812 INFO [com.smartfoxserver.v2.controllers.SystemController-1] v2.controllers.SystemController - {IN}: Handshake
11 Mar 2011 17:58:00,384 INFO [Scheduler1-thread-1] bitswarm.sessions.DefaultSessionManager - Session removed: { Id: 25, Type: DEFAULT, Logged: No, IP: 127.0.0.1:39268 }

Lof at the c# console;
[SFS -DEBUG] Handshake respınse : tk => smthingsmthing, ct => 1024
[SFS - ERROR] TCPSocketLayer: Connection closed by the remote side

So after a while after the handshake smartfox closes the connection and onConnection event is never triggered.

I managed to connect in Smartfox 1.6 the same way.( I've changed my code according to Smartfox2x of course. )

Anybody has an idea why this is happening?

Any help is appreciated.

Thank you.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Post by ThomasLund »

The typical scenario for this is, that you are running the API in "thread safe mode" - which is the default in the SFS2X API due to issues with Unity not being thread safe.

Either manually turn this off on your SmartFox instance - or set up a scheduled loop to trigger emptying the event queue.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
GoaKoala
Posts: 5
Joined: 11 Mar 2011, 17:10

Post by GoaKoala »

Hello Thomas;

Thanks for the answer. Maybe it'll be a stupid question but how do i turn "thread safe mode" in my smartfox instance?

I've checked the admin tool and looked through the config xml's but didn't see an option for that.

Thank you.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Post by ThomasLund »

Ahhh - looking in the wrong end. Its a client side setting on the SmartFox instance.

Code: Select all

        /// <summary>
        /// When true (default) sets the API to be run with an event queue that needs to be processed from the client
        /// </summary>
        /// <remarks>
        /// When run in Unity, this <b>has</b> to be true. Otherwise you will get random crashes.
        /// </remarks>
        /// <seealso cref="ProcessEvents"/>
		public bool ThreadSafeMode {
by doing something like

Code: Select all

			SmartFox sfs = new SmartFox();
			sfs.ThreadSafeMode = false;
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
GoaKoala
Posts: 5
Joined: 11 Mar 2011, 17:10

Post by GoaKoala »

Thank you sir. As you have saved my day. :)

Problem is solved now.

Cheers. :)
Post Reply