spaceraces example UDP not workin on latest SFS2 api

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

spaceraces example UDP not workin on latest SFS2 api

Postby levancho » 31 Mar 2012, 23:57

game itself works but,it seems that UDP protocol is not working
I have compiled both client and server code with latest API jar/swf

I am still getting following error in console:


Code: Select all

 DEFAULT, Logged: Yes, IP: 127.0.0.1:53294 }
19:53:48,942 WARN  [SocketWriter-1] core.SocketWriter     -
java.lang.IllegalStateException: UDP Packet cannot be sent to: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:53294
}, no DatagramChannel was ever set!
        com.smartfoxserver.bitswarm.core.SocketWriter.udpSend(SocketWriter.java:490)
        com.smartfoxserver.bitswarm.core.SocketWriter.processRegularSession(SocketWriter.java:287)
        com.smartfoxserver.bitswarm.core.SocketWriter.processSessionQueue(SocketWriter.java:209)
        com.smartfoxserver.bitswarm.core.SocketWriter.run(SocketWriter.java:185)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)

 WARN 2012-03-31 19:53:48,942 com.smartfoxserver.bitswarm.util.Logging:
java.lang.IllegalStateException: UDP Packet cannot be sent to: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:53294
}, no DatagramChannel was ever set!
        com.smartfoxserver.bitswarm.core.SocketWriter.udpSend(SocketWriter.java:490)
        com.smartfoxserver.bitswarm.core.SocketWriter.processRegularSession(SocketWriter.java:287)
        com.smartfoxserver.bitswarm.core.SocketWriter.processSessionQueue(SocketWriter.java:209)
        com.smartfoxserver.bitswarm.core.SocketWriter.run(SocketWriter.java:185)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)
User avatar
Lapo
Site Admin
Posts: 21522
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: spaceraces example UDP not workin on latest SFS2 api

Postby Lapo » 01 Apr 2012, 08:00

Make sure that you configured SFS to listen for UDP packets. Launch the AdminTool > Server Configurator.
Mine looks like this:
Image
Lapo
--
gotoAndPlay()
...addicted to flash games
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 10 Apr 2012, 03:04

I am also having this problem after doing an install of the latest release. I have added both TCP and UDP socket addresses for localhost, my wireless card, and my vpn link just to make sure everything is covered, and I still can't send UDP packets.

Do you have any other suggestions?
User avatar
Lapo
Site Admin
Posts: 21522
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: spaceraces example UDP not workin on latest SFS2 api

Postby Lapo » 10 Apr 2012, 07:05

You should explain which errors do you get. Check your logs on the server side. If UDP has failed you will find errors in there.
Lapo

--

gotoAndPlay()

...addicted to flash games
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 10 Apr 2012, 15:57

I get the same error as listed above.

From my server log:


09 Apr 2012 | 20:01:04,204 | INFO | pool-1-thread-3 | v2.api.SFSApi | | Login in, { Zone: BattleBratsAlpha }, ( User Name: Russ, Id: 8, Priv: 0, Sess: 127.0.0.1:50020 )
09 Apr 2012 | 20:01:04,224 | WARN | SocketWriter-1 | bitswarm.core.SocketWriter | | Error during write. Session: { Id: 9, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:50020 }
09 Apr 2012 | 20:01:04,225 | WARN | SocketWriter-1 | bitswarm.core.SocketWriter | |
java.lang.IllegalStateException: UDP Packet cannot be sent to: { Id: 9, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:50020 }, no DatagramChannel was ever set!
com.smartfoxserver.bitswarm.core.SocketWriter.udpSend(SocketWriter.java:490)
com.smartfoxserver.bitswarm.core.SocketWriter.processRegularSession(SocketWriter.java:287)
com.smartfoxserver.bitswarm.core.SocketWriter.processSessionQueue(SocketWriter.java:209)
com.smartfoxserver.bitswarm.core.SocketWriter.run(SocketWriter.java:185)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 11 Apr 2012, 17:12

I can provide config files if needed. This is kind of a showstopper.
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 12 Apr 2012, 15:05

Could I perhaps pay someone to help me with this issue?

Here's the relevant bit from my server.xml:


<serverSettings>
<socketAddresses>
<socket address="127.0.0.1" port="9933" type="TCP"/>
<socket address="127.0.0.1" port="9933" type="UDP"/>
<socket address="192.168.1.4" port="9933" type="UDP"/>
<socket address="192.168.137.20" port="9933" type="UDP"/>
<socket address="192.168.137.20" port="9933" type="TCP"/>
<socket address="192.168.1.4" port="9933" type="TCP"/>
</socketAddresses>

The server receives UDP packets fine. The error occurs when it tries to send UDP.
User avatar
Bax
Site Admin
Posts: 4515
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby Bax » 13 Apr 2012, 10:03

When you start the game, it shows a login panel where the port number for UDP communication is requested. Are you sure the default value is 9933? Because we had this set to 9934 previously (on the latest examples package release this was changed to 9933, if I remember correctly).
Paolo Bax
The SmartFoxServer Team
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 13 Apr 2012, 15:06

I should clarify: I am not running spaceraces, I am getting this error in the game I am developing.

I verified that I am connecting to 9933. The server receives UDP packets from the client with no complaints, and this code works fine on the 2x beta version I was running.
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 16 Apr 2012, 16:36

Is there any other information I can provide on this? I really do need to use UDP.
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 17 Apr 2012, 16:27

I hate to be a pest, but I am planning on releasing my game fairly soon. Is this something that can be fixed?
User avatar
Bax
Site Admin
Posts: 4515
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby Bax » 18 Apr 2012, 10:30

We are not aware of problems. If you check the SpaceRace game you will see it works perfectly, using the UDP communication.
Same with other non-AS3 examples. So I believe you are doing something wrong, even if it is hard to spot.
Can you provide a test case showing the issue? (please don't send your entire game).
Paolo Bax
The SmartFoxServer Team
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 18 Apr 2012, 22:15

Ok, I created a small test case, and emailed it to info@smartfoxserver.com. Please let me know if you need any more info, and thanks for your help.
User avatar
Lapo
Site Admin
Posts: 21522
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: spaceraces example UDP not workin on latest SFS2 api

Postby Lapo » 19 Apr 2012, 07:59

You are not waiting for the UDP initialization to complete. In your code there's no UDP_INIT event handler.
Please check the snippet provided in the documentation under SmartFox.InitUDP() method:
http://docs2x.smartfoxserver.com/api-do ... Index.html
Lapo

--

gotoAndPlay()

...addicted to flash games
HumanPoweredGames
Posts: 71
Joined: 19 Oct 2011, 16:40
Location: Alaska
Contact:

Re: spaceraces example UDP not workin on latest SFS2 api

Postby HumanPoweredGames » 19 Apr 2012, 23:24

Thank you for looking into it... you found my problem. Sorry to bother you with that.

One other thing I discovered is that you have to call InitUDP() AFTER you log in to the zone, or the UDP_INIT callback never happens, and the session just times out.

Here's my connection code, for anyone else who might be having trouble:

Code: Select all

using UnityEngine;
using System.Collections;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;

public class UDPTest : MonoBehaviour
{
   
   SmartFox smartFox = new SmartFox();
   void  Start ()
   {
      string host = "192.168.1.4";
      int port  = 9933;
      string userName = "Bill";
      string password = "Blearg";
      string zone = "BattleBratsAlpha";
      
      print ("connecting");
      smartFox.Connect(host, port);
      
      smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, delegate
      {   
            print("Connection lost");   
      } );
      
      smartFox.AddEventListener(SFSEvent.CONNECTION, delegate(BaseEvent evt)
      {
         bool success = (bool)evt.Params["success"];   
         if(success)
         {   
            print("connected");   
            smartFox.Send( new LoginRequest(userName, password, zone) );
         }
         else
            print( "Connect failed: " + (string)evt.Params["errorMessage"]);
      } );

   
      smartFox.AddEventListener(SFSEvent.LOGIN_ERROR, delegate(BaseEvent evt)
      {   
         print( "Login failed:" + (string)evt.Params["errorMessage"] );   
      } );

      smartFox.AddEventListener(SFSEvent.LOGOUT, delegate(BaseEvent evt)
      {   
         print( "Logged out:" );   
      } );

      smartFox.AddEventListener(SFSEvent.LOGIN, delegate(BaseEvent evt)
       {   
         print ("logged In");
         smartFox.InitUDP(host, port);
      } );
      
      smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, delegate(BaseEvent evt)
      {
         string cmd = evt.Params["cmd"] as string;
         print(cmd);
      } );
      
      smartFox.AddEventListener(SFSEvent.UDP_INIT, delegate(BaseEvent evt)
      {
         if ((bool)evt.Params["success"])         
         {   
            print ("UDP Initialized");
            StartCoroutine(PingIt ());
         }
         else
            print ("UDP Failed");         
      });
      
   }
}

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 13 guests