UDP Parameter Error

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Gnoll
Posts: 128
Joined: 10 Mar 2009, 10:14

UDP Parameter Error

Postby Gnoll » 08 Nov 2010, 07:05

Hi Lapo,

I am using Adobe AIR SDK 2 and trying to use the initUDP functionality. When I call unitUdp(new AirUDPManager(); with the correct settings in the config, or manually specifying the host\port I get the error:

ArgumentError: Error #2004: One of the parameters is invalid.
at flash.net::DatagramSocket/internalConnect()
at flash.net::DatagramSocket/connect()
at com.smartfoxserver.v2.bitswarm::AirUDPManager/initialize()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/bitswarm/AirUDPManager.as:92]
at com.smartfoxserver.v2::SmartFox/initUDP()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/SmartFox.as:587]
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 08 Nov 2010, 14:26

Wow! Pretty weird :(
The exception seems to be fired by the AIR Datagram class.

Can you please provide all the details of your project and maybe the source code? (via email if it's long or if you don't want to post it here)
I would like to know the exact version of the AIR sdk and settings of the project.
Lapo
--
gotoAndPlay()
...addicted to flash games
Gnoll
Posts: 128
Joined: 10 Mar 2009, 10:14

Postby Gnoll » 08 Nov 2010, 23:10

Okay here is the only class currently:

Code: Select all

package
{
   import com.luaye.console.C;
   import com.smartfoxserver.v2.bitswarm.AirUDPManager;
   import com.smartfoxserver.v2.core.SFSEvent;
   import com.smartfoxserver.v2.requests.LoginRequest;
   import com.smartfoxserver.v2.SmartFox;
   import flash.display.Sprite;
   import flash.net.DatagramSocket;
   
   /**
    * ...
    * @author Josh C
    */
   public class Main extends Sprite
   {
      
      private var sfs:SmartFox = new SmartFox();
      
      public function Main():void
      {
         C.start(this, "~");
         
         sfs.addEventListener(SFSEvent.CONNECTION, onConnection);
         sfs.addEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost);
         sfs.addEventListener(SFSEvent.LOGIN, onLogin);
         sfs.addEventListener(SFSEvent.LOGIN_ERROR, onLoginError);
         sfs.addEventListener(SFSEvent.UDP_INIT, onUDPInit);
         
         sfs.loadConfig("config/sfs-config.xml");
      }
      
      private function onConnection(e:SFSEvent):void
      {
         trace("Connected");
         sfs.send(new LoginRequest("test"));
      }
      
      private function onConnectionLost(e:SFSEvent):void
      {
         trace("Connection lost");
      }
      
      private function onLogin(e:SFSEvent):void
      {
         trace("Login success");
         sfs.initUDP(new AirUDPManager());
      }
      
      private function onLoginError(e:SFSEvent):void
      {
         trace("Login failed");
      }
      
      private function onUDPInit(e:SFSEvent):void
      {
         trace("UDP initialisation " + e.params.success ? "succeeded" : "failed");
      }
      
      private function trace(... args):void
      {
         C.info(args);
      }
      
   }
   
}


The config contains this along with other things:

Code: Select all

<udpIp>myhostname</udpIp>
<udpPort>9933</udpPort>


The build.xml is using <application xmlns="http://ns.adobe.com/air/application/2.0"> Although it is Adobe AIR 2.5 SDK in the readme.[/code]
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 09 Nov 2010, 09:59

Hmmm... interesting. My question would be... how do you know which version of the Air 2.x SDK are you using? :D
I've spent quite a bit of time searching in the preferences of FlashBuilder 4 to no avail. Any ideas?
Lapo

--

gotoAndPlay()

...addicted to flash games
Gnoll
Posts: 128
Joined: 10 Mar 2009, 10:14

Postby Gnoll » 10 Nov 2010, 05:32

I am using the flex_sdk and in my case it is found inside C:\flex_sdk_4\AIR SDK Readme.txt

Not sure if it is building with 2.5, does 2.0 in the xml make it 2.x? Putting 2.5 in that xml tag doesn't work however.

I also tried with flex_sdk_3 with AIR2 with no luck.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 10 Nov 2010, 06:57

Then it's even more strange! :shock:
Please drop us an email referencing this post and we'll send you a test application to compile on your side.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Gnoll
Posts: 128
Joined: 10 Mar 2009, 10:14

Postby Gnoll » 10 Nov 2010, 19:11

Hi Lapo,

I created a Flex4 Air Application, configured it the same as my old one, and used your mxml and had no error... Went back to an Actionscript Project with the same configuration and it all blew up again! Really weird, it is an error with my system though, previously I could use the Datagram socket but just opening the socket and telling it to connect now says there is a parameter error.

Code: Select all

var sock:DatagramSocket = new DatagramSocket();
         sock.connect("localhost", 9933);


Noticed a typo "[SFS - WARN] UPD initialization is already in progress!"

I'll keep trying to figure it out,
Thanks,
Josh[/code]
Gnoll
Posts: 128
Joined: 10 Mar 2009, 10:14

Postby Gnoll » 11 Nov 2010, 03:02

So...

Your example used 127.0.0.1 as the host, while mine used a domain name. Datagram sockets don't support DNS??

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

Postby Lapo » 11 Nov 2010, 05:20

I didn't expect this but you might have caught the problem! :O
According to the Adobe docs, the DatagramSocket says:

remoteAddress:String — The IP address of the remote machine with which to establish a connection. This address can be an IPv4 or IPv6 address. If bind() has not been called, the address family of the remoteAddress, IPv4 or IPv6, is used when calling the default bind().


http://help.adobe.com/en_US/air/referen ... l#connect()

This explains the error you reported from the DatagramSocket class.
Seems like only IP addresses are accepted :(
Lapo

--

gotoAndPlay()

...addicted to flash games
Gnoll
Posts: 128
Joined: 10 Mar 2009, 10:14

Postby Gnoll » 11 Nov 2010, 07:05

That's quite interesting.

Could we possibly resolve this through the TCP connection, getting the ip?? I assume sfs.currentIp would store the url or ip instead of resolving to ip right?

I seem to have lots of problems having a dynamic ip and dns!!

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 20 guests