Unity API UDP init issue after close

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

Moderators: Lapo, Bax

jamescol
Posts: 1
Joined: 01 Jan 2015, 09:25

Unity API UDP init issue after close

Postby jamescol » 02 Jan 2015, 12:57

Hi everyone.

I have been developing a game initially based off the fpsExample using Unity / SFS for aprox 7 months.
I have only just launched the production environment and have run into an issue in the last 2 days when moving the SFS to an Amazon EC2 environment.

The issue happens in both production environments:
Amazon EC2 Linux w/mySQL database (which contains login info).
Amazon EC2 Windows Server R2 connecting to remote mySQL database (which contains login info)

Running:
Latest SmartFoxServer2X
Unity 4.5.5
Latest C# unity API dll.

Basically if the login screen (or any screen calling the smartFox.Connect method) A session is created for the user on the server and I can then login. I can then logout via a logout button then successfully login again.
If I then force close the application and reopen it for the next few minutes I cannot login again. The login appears to successfully authenticate however the UDP cannot be initiated again. If I wait a few minutes before I reopen the game the UDP will initiate successfully on a login attempt.
See the following code snippet of my onLogin method:

Code: Select all

public void OnLogin(BaseEvent evt) {
      bool success = true;
      if (evt.Params.Contains("success") && !(bool)evt.Params["success"]) {
         // Login failed - lets display the error message sent to us
         loginErrorMessage = (string)evt.Params["errorMessage"];
         Debug.Log("Login error: "+loginErrorMessage);
      } else {
         // Startup up UDP
         if(smartFox.UdpInited) {
            Debug.Log("UDP already initiated ... logging in");
            if(!registering) {
               Application.LoadLevel("lobby");
            } else {
               Application.LoadLevel("register");
            }
         } else {
            Debug.Log("UDP not init... Attempting init");
            smartFox.InitUDP(serverName, serverPort);
         }
      }         
   }


When InitUDP method is called the client tries 3 attempts before timing out. However the server logs show the following WARN when the attempt is made:

Code: Select all

Client already UDP inited: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 20X.XX.XX.XX:5XXXX }


So the server still has UDP initiated for this client from the previous session it seems however the clients check doesn't see this as initiated the OnUdpInit method gets back a failed attempt. The only thing I can thing of is multiple sessions for the same user on these instances or the failure to drop the UDP on logout. of the server but that doesn't help explain why my local instance doesn't have the same issue.
I wouldn't be so puzzled if it also didn't work on my test environment (My local computer Windows 8.1 SQL EXPRESS) even when connecting to the server and playing the game remotely eg public WIFI I cannot reproduce this error on this server.

I have tried multipule solutions on both client and server including calling smartFox.disconnect() on application close (Client) and attempted to remove any sessions of that used in my OnUserGoneHandler all without luck.
The application is primary for mobile devices where the application with be force quit then reopened often so this is an important error for me to try resolve.

Can anyone shed some light on this issue?
Help is much appreciated.
Regards,
James
User avatar
Chadrien
Posts: 5
Joined: 30 Sep 2016, 11:40
Location: Paris

Re: Unity API UDP init issue after close

Postby Chadrien » 18 Jan 2017, 16:51

Hi

I have the same problem on my linux amazon EC2.

Still no answer?

Thx
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity API UDP init issue after close

Postby Lapo » 19 Jan 2017, 08:29

Hi,
this thread is 2 years old and honestly I don't remember how we dealt with this. Sometimes folks post here and also send us an email and we end up discussing it there.

In any case, I'd recommend starting a new thread posting the details of the problem, the version of SFS2X, API and Unity in use and any other info that might be useful (e.g. log messages)

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 22 guests