Of course you will get those errors in the console if the Server is not running!
I realize this, but...
Also you will get the connection event with the success parameter set to false.
The problem is that I am
not getting that callback, ever.
If this is not happening we then need you to send us a stripped down code example that we can use to see what you are talking about.
Here's some sample code that reproduces this for me:
Code: Select all
package
{
import com.bit101.components.HBox;
import com.bit101.components.PushButton;
import com.bit101.components.Window;
import com.smartfoxserver.v2.SmartFox;
import com.smartfoxserver.v2.core.SFSEvent;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
public class SmartfoxBugRepro extends Sprite
{
private var mSfs:SmartFox;
private var mConnectButton:PushButton;
private var mDisconnectButton:PushButton;
public function SmartfoxBugRepro()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var window:Window = new Window(stage, 0, 0, "Test Client");
window.width = 300;
window.height = 100;
var hbox:HBox = new HBox(window, 10, 10);
mConnectButton = new PushButton(hbox, 0, 0, "Connect", ConnectClickedCB);
mDisconnectButton = new PushButton(hbox, 0, 0, "Disconnect", DisonnectClickedCB);
mDisconnectButton.enabled = false;
}
private function ConnectClickedCB(event:Event):void
{
trace("Connecting to server...");
CreateSmartfoxConnectionObject();
mSfs.connect("localhost", 9933);
mConnectButton.enabled = false;
}
private function DisonnectClickedCB(event:Event):void
{
trace("Disconnecting from server...");
if (mSfs != null)
{
mSfs.disconnect();
}
}
private function CreateSmartfoxConnectionObject():void
{
if (mSfs)
{
mSfs.disconnect();
mSfs.removeEventListener(SFSEvent.CONNECTION, OnConnection);
mSfs.removeEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
mSfs = null;
}
mSfs = new SmartFox();
mSfs.useBlueBox = true; // Toggle this!
mSfs.debug = true;
mSfs.addEventListener(SFSEvent.CONNECTION, OnConnection);
mSfs.addEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
trace("SmartFox API: " + mSfs.version);
}
private function OnConnection(event:SFSEvent):void
{
trace("OnConnection. Success: " + event.params.success);
if (event.params.success)
{
mDisconnectButton.enabled = true;
}
else
{
mConnectButton.enabled = true;
}
}
private function OnConnectionLost(event:SFSEvent):void
{
trace("OnConnectionLost. Reason: " + event.params.reason);
mDisconnectButton.enabled = false;
mConnectButton.enabled = true;
}
}
}
This uses just the SFS API, and MinimalComps (
http://code.google.com/p/minimalcomps/d ... 0_9_10.swc).
When I run this locally, it behaves as expected, and I get all the events I should be getting. But as soon as I put it on a web server, and hit it from there, I no longer get the connection failed event. Instead, I get an uncaught security exception.
Code: Select all
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://dev.foo.com/test/dynamic/tomg/bin-debug/SmartfoxBugRepro.swf cannot load data from http://localhost:8080/BlueBox/BlueBox.do.
at com.smartfoxserver.v2.bitswarm.bbox::BBClient/getLoader()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/API/AS3/src/com/smartfoxserver/v2/bitswarm/bbox/BBClient.as:231]
at com.smartfoxserver.v2.bitswarm.bbox::BBClient/sendRequest()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/API/AS3/src/com/smartfoxserver/v2/bitswarm/bbox/BBClient.as:224]
at com.smartfoxserver.v2.bitswarm.bbox::BBClient/connect()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/API/AS3/src/com/smartfoxserver/v2/bitswarm/bbox/BBClient.as:114]
at com.smartfoxserver.v2.bitswarm::BitSwarmClient/connect()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/API/AS3/src/com/smartfoxserver/v2/bitswarm/BitSwarmClient.as:252]
at com.smartfoxserver.v2::SmartFox/handleConnectionProblem()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/API/AS3/src/com/smartfoxserver/v2/SmartFox.as:1935]
at com.smartfoxserver.v2::SmartFox/onSocketSecurityError()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/API/AS3/src/com/smartfoxserver/v2/SmartFox.as:1790]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.smartfoxserver.v2.bitswarm::BitSwarmClient/onSocketSecurityError()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/API/AS3/src/com/smartfoxserver/v2/bitswarm/BitSwarmClient.as:454]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::Socket/onTimeout()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Could you please verify that you get the same behaviour? If so, is there a way to avoid this, and get a proper connection failure in this case?
Thanks!