Solved: failed connection not handled

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

paintbrush
Posts: 19
Joined: 06 Mar 2008, 07:12

Solved: failed connection not handled

Postby paintbrush » 11 Mar 2008, 03:19

NOTE: For those who do not wish to swim through so much text, I summarized the problem in the second message in this thread. Come back to this message for more detail!

Update: Found the fix to the problem and posted it on the 3rd message in this thread. A new issue/question sprouts though, relating to BlueBox.

Hey all,

I've been getting the hang of SFS pretty quickly. An old problem comes back to haunt me though... for those who recall my earlier post, failed connections weren't calling the SFC.onConnection handler, making me hard to debug and isolate the real problem I had. It didn't bother me as much before because I was just concerned with building a working app, but now that I have something substantial I would like to handle a failed connection error gracefully with a UI notice. I'm currently using the AS3 libraries that come with SFS PRO. This is the isolated code I'm testing this with:

Code: Select all

package{
   import it.gotoandplay.smartfoxserver.*;
   import flash.display.*;
   public class simple extends MovieClip{
      var sfs:SmartFoxClient;
      public function simple(){
         sfs = new SmartFoxClient(true);
         sfs.addEventListener(SFSEvent.onConnection,connectionHandler);
         sfs.connect(<MY IP>,9339);
      }
      private function connectionHandler(e:SFSEvent):void{
         trace('conn');
      }
   }
}

Naturally, replace <MY IP> with what the SFS server IP. In this scenario, the console window should still print 'conn' regardless of whether the connection was successful or not, since the connectionHandler is invoked in both cases, just that the e.params variable will hold different things based on the outcome. Running this app with SFS running connects and prints 'conn' as expected, but running this app with SFS not running does not print 'conn', when it is expected to do so.

Here's a weird observation: when I have <MY IP> set to '127.0.0.1', it does go through the whole thing and performs the output as expected regardless of whether SFS is running or not (this only happens when I'm running the app either right from Flash or from my local machine). But when I set <MY IP> to my machine's true IP address, it seems to hang and refuse to throw any errors. In the latter case, is SFS trying to connect, and refusing to time out and throw an error?

I've been tearing my hair out on this problem since last night, so I'd dearly appreciate any help you guys can offer!

UPDATE: when running it within Adobe Flash CS3 using my machine's full IP address to connect, it eventually did as it was supposed to, but took a looooong time (around 1 minute for the first debug message to appear). When i ran it on a browser however, it was just stuck, with my browser's status bar saying "Connecting to <IP address I specified>..." This one didn't budge. Is there anything I can do to make it time out faster? Note that editing any of the SFS config files won't help since I'm trying to simulate a situation when SFS is completely offline.

-Jay
Last edited by paintbrush on 13 Mar 2008, 22:27, edited 3 times in total.
paintbrush
Posts: 19
Joined: 06 Mar 2008, 07:12

Postby paintbrush » 11 Mar 2008, 20:22

Perhaps that was too long-winded. So I'll summarize :P

The gist of the problem:
The Flash movie that attempts to connect to a non-existent SFS server does not seem to invoke the onConnection handler in a timely fashion, when it should in order to throw an error. As a result, any such attempts would seem like a hang.

Anyone else experienced this, or have a suggestion for a fix?
Last edited by paintbrush on 13 Mar 2008, 19:27, edited 1 time in total.
paintbrush
Posts: 19
Joined: 06 Mar 2008, 07:12

Solved!

Postby paintbrush » 13 Mar 2008, 19:09

Solution:
Alright, after doing extensive testing with every variable and listener documented, I found out that setting the SFC's smartConnect variable to 'false' fixed this problem.

This brings up another question, however:
If smartConnect is enabled by default (i.e. 'connect to BlueBox if socket port is not available'), that means this problem is related to the SFC object not throwing an error if it doesn't find BlueBox. What's the proper way to handle a non-existent BlueBox connection?

(I'm still concentrating on the SFS client and starting extensions right now, so I haven't delved much into BlueBox or RedBox. Please bear with my newbieness while I learn <3 and thanks so much for your patience!)

Apologies
I did a search for 'smartConnect' on the forums and realized that this very question had already been answered in January :oops: Believe me when I say I tried searching for the solution to this problem on the forum before posting, but not knowing how other people describe the problem/not knowing the potential solution gave me little for PHPBB's search function to work with. I hope I didn't make a fool of myself/rubbed people the wrong way asking these questions in my first few days on this forum :? If I did/have however, you have my due apology.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 65 guests