Unity client freezes when disconnected by server.

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

Moderators: Lapo, Bax

HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Unity client freezes when disconnected by server.

Postby HumanPoweredGames » 22 Sep 2012, 19:08

I'm having a problem where if the server disconnects the Unity client with getAPI().disconnectUser, the client will freeze. The really strange thing is this freeze happens with the Unity Editor, and players for OSX and Linux, but not on iOS.

I think this is happening when the client tries to send a message after the server has disconnected it, but before isConnected gets set to false. Is there something I can check besides isConnected to determine whether the connection is up before I call Send? Any other suggestions for fixing this.
User avatar
Lapo
Site Admin
Posts: 21602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity client freezes when disconnected by server.

Postby Lapo » 23 Sep 2012, 08:13

We release a Unity API update just a week ago. Can you confirm that you are using the latest?
If not please upgrade and let us know:
http://www.smartfoxserver.com/download/sfs2x#p=updates

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: Unity client freezes when disconnected by server.

Postby HumanPoweredGames » 23 Sep 2012, 18:38

I hadn't known that. I will download and try it.

Thanks
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: Unity client freezes when disconnected by server.

Postby HumanPoweredGames » 24 Sep 2012, 18:01

I did the update, but I'm still getting the freezes.

Here's a little more detail:

My client sends UDP messages containing character updates ever 150ms. It appears to be this send that is causing the crash when the server disconnects the client rudely, either with disconnectUser or by shutting down the server. This seems to be the only situation where I have the crashes.

I have tried disconnecting the client computer from the network during the play, and this does not happen... it happily reconnects and resumes when I reconnect the network.

In all other situations, my CONNECTION_LOST event fires correctly, and everything works as expected.

Edit:

I devised a workaround that sends a message to the clients telling them a disconnect is coming, and then disconnects after a short delay. This should cover me for anything but the server process crashing, which I don't expect to ever see.

So I'm good.
User avatar
Lapo
Site Admin
Posts: 21602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity client freezes when disconnected by server.

Postby Lapo » 26 Sep 2012, 07:53

Thanks for reporting. I will ask ThomasLund to take a looks and see if he can reproduce it.
Lapo

--

gotoAndPlay()

...addicted to flash games
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: Unity client freezes when disconnected by server.

Postby ThomasLund » 27 Sep 2012, 10:00

We have not been able to reproduce any types of crashes on disconnect with the 1.0.3 version.

If you have any repro case, please send it over and I'll take a look! Otherwise will try to repro it with server shutdown (we've tried that several times and not had issues anymore)

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
freaka61
Posts: 12
Joined: 24 Jul 2012, 13:29

Re: Unity client freezes when disconnected by server.

Postby freaka61 » 30 Dec 2012, 19:28

it freezes because you don't close old opened SmartFox connection. You should close old SmartFox(); instance.
User avatar
nekokiller
Posts: 24
Joined: 23 Oct 2012, 10:13

Re: Unity client freezes when disconnected by server.

Postby nekokiller » 26 Feb 2013, 08:20

How to close old SmartFox(); instance. ?

Make a new one ? ( new SmartFox() ? )

But that will cause the threads number of the application be more and more. The application will be busy and dead soon.

Is there anybody work on Unity crash problem ?
User avatar
Lapo
Site Admin
Posts: 21602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity client freezes when disconnected by server.

Postby Lapo » 26 Feb 2013, 16:25

What you need to do is remove the old listeners on the previous SmartFox instance, then create a new instance.
It is actually pretty simple to do if you setup and init() and destroy() methods in which you respectively add and remove the listeners that you need.

All it remains to do is just passing the current SmartFox instance and the problem is solved.
Lapo

--

gotoAndPlay()

...addicted to flash games
anniyan137
Posts: 25
Joined: 20 Nov 2012, 10:49

Re: Unity client freezes when disconnected by server.

Postby anniyan137 » 14 Mar 2013, 05:49

I too seem to have this problem sometimes. One situation when I observed this, is when I restarted the server (standalone for debugging). The Unity web player crashes. I would have to even force close the browser to end it.

I have just downloaded the new C# API. Will test it on that too and get back.
User avatar
Lapo
Site Admin
Posts: 21602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity client freezes when disconnected by server.

Postby Lapo » 14 Mar 2013, 10:10

Yes please, let us know.
Lapo

--

gotoAndPlay()

...addicted to flash games
tichfuie
Posts: 26
Joined: 28 Aug 2012, 21:53

Re: Unity client freezes when disconnected by server.

Postby tichfuie » 15 Apr 2013, 03:39

same issue here,
i downloaded the new api and now when i shutdown the server my client disconnects and takes me to the login screen, thank you for that fix which was not happening with old api,
but......
after the disconnection and while on the login screen, my client just freezes, am not even able to shut the unity client or reconnect if i start server, have to kill the unity client app process with windows task manager.

hopefully there will be a fix for this issue
User avatar
Lapo
Site Admin
Posts: 21602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity client freezes when disconnected by server.

Postby Lapo » 15 Apr 2013, 08:00

Can you please provide more details?
Which Unity version are you using? Under Mac or Windows?
Are you testing in the Editor or not? If not what kind of client are you building?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
tichfuie
Posts: 26
Joined: 28 Aug 2012, 21:53

Re: Unity client freezes when disconnected by server.

Postby tichfuie » 15 Apr 2013, 16:20

using latest up to date unity 4.1.2
Smartfox server 2.6

windows 7 64 platform and running the server on windows aswell

same issue happens while in editor mode and in windows build unity client


hope this helps you.
User avatar
Lapo
Site Admin
Posts: 21602
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity client freezes when disconnected by server.

Postby Lapo » 16 Apr 2013, 09:44

after the disconnection and while on the login screen, my client just freezes, am not even able to shut the unity client or reconnect if i start server, have to kill the unity client app process with windows task manager.

Over here we don't use Windows very much, mostly MacOS X but I have seen several reports from Windows user (there's another recent thread).

I've now tested using the latest Unity Editor 4.1.2 under both Win 7 and 8 and I have been able to reproduce the editor crash just like you reported, although it seems intermittent.
If we build an executable the problem doesn't show up.

It definitely looks like a Unity editor problem, we'll report the bug to the Unity dev team.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 4 guests