UDP and Disconnect

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

Moderators: Lapo, Bax

Wolfenbr
Posts: 4
Joined: 30 Dec 2010, 17:43
Location: US

UDP and Disconnect

Postby Wolfenbr » 14 Feb 2011, 01:58

So i created a custom login and every time a user tries to login and he's already logged in, i just disconnect him and let the login proceed. It used to work just fine, one client would drop and the other would just login.

The problem is, now i'm using UDP and when the second client connects (after the first client gets disconnected), it can't initialize the UDP anymore. Instead, the server just hangs for a few seconds and disconnects the second client too.

I got the udp working and this problem only occurs when the user is already logged and my custom login disconnects him so the same user can connect from somewhere else.

Any idea on how to solve this? Maybe another way to disconnect/login a client if he's already logged in?

I'm using unity as client by the way.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 16 Feb 2011, 16:05

Moved in proper section.
Lapo
--
gotoAndPlay()
...addicted to flash games
spart
Posts: 4
Joined: 22 Feb 2011, 03:44

Postby spart » 22 Feb 2011, 03:55

I'm witnessing the same exact symptom! Using Unity with InitUDP, and server stops responding after a user logs in as someone already logged in, disconnecting the latter in the process via custom login code.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 22 Feb 2011, 07:26

Do you have a small repro case that I can run here in my end?
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
spart
Posts: 4
Joined: 22 Feb 2011, 03:44

Postby spart » 22 Feb 2011, 14:06

I'm at work, so I don't have access to my code right now, but here's basically what it is in my custom login handler:

Code: Select all

public class LoginEventHandler extends BaseServerEventHandler
{
  public void handleServerEvent(ISFSEvent event) throws SFSException
  {
    String name = (String) event.getParameter(SFSEventParam.LOGIN_NAME);
    Zone zone = getParentExtension().getParentZone();
    User user = zone.getUserByName(name);
    if (user != null)
    {
      getApi().disconnectUser(user);
    }

    // Proceed with login...


In the Unity client I have InitUDP called in the OnLogin function just like in your FPS example. Everything works fine if i comment out

Code: Select all

getApi().disconnectUser(user);
, but I'm not able to log a user off if he's logging in from somewhere else without the server losing responsiveness.

Let me know if this is enough info.. otherwise, I'll be home later and can give you more details. Thanks.[/code]
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 22 Feb 2011, 17:49

Sounds like the same as here viewtopic.php?t=10205

So some bug in reconnecting a connected/disconnected connection (phew - what a sentence). Possibly UDP only.

Will put it on my todo list. I got a quite hectic week this week before GDC - launching a game. So most likely will not be looked at before weekend. Hope thats ok

/T
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
spart
Posts: 4
Joined: 22 Feb 2011, 03:44

Postby spart » 22 Feb 2011, 18:11

No prob. Look forward to hearing back, and have fun at the GDC.
spart
Posts: 4
Joined: 22 Feb 2011, 03:44

Postby spart » 12 Mar 2011, 15:40

Any update on this?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 12 Mar 2011, 15:47

Yeh - been looking at it, and the bigger fix will take a little extra time + discussions with the server guys.

You more or less can work around the issue. Dont rely on the callback from InitUDP, but check if udp is inited and then do what you would otherwise have done.

UDP stays initialized after a logout - thats the thing biting you.

So if you e.g. usually in your login sequence join the lobby after initializing network, then do something like this:

Code: Select all

if (!smartFox.UdpInited) {
   smartFox.InitUDP(serverName, serverPort);
}
else {
   JoinLobby();
}
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
creat326
Posts: 87
Joined: 13 Jun 2010, 09:50

Postby creat326 » 12 Apr 2011, 20:29

heh, great... i've spent a month trying to figure out what was causing my server to not accept more connections and today I find it and I see it was a known issue grrrr

The problem is that doing this temporary fix would require to modify all my clients, which would take a couple weeks to propagate. So it's a bit of a pain. So far what I've done is create a windows server that every 5 minutes connects to the server and in case it fails, it will restart the smartfox insntace.

Any plans on releasing an update with a fix for this soon?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 13 Apr 2011, 08:03

I do not know the plans for next release.

/me looks at Marco
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
creat326
Posts: 87
Joined: 13 Jun 2010, 09:50

Postby creat326 » 13 Apr 2011, 09:48

/me looks at Thomas and Marco, tapping the table...
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Apr 2011, 10:00

The bug was added to the bug DB some time ago and it will be taken care of before the next release.
thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
creat326
Posts: 87
Joined: 13 Jun 2010, 09:50

Postby creat326 » 21 Apr 2011, 11:00

no rush. it's only been two months since first reported
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 29 Jun 2011, 06:27

Fixed in RC3, check the update from the download page.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 60 guests