Jacks_Depression

Jacks_Air Wall

Posted: 2010.09.03 13:30

Just a quick hint to help anyone else with the following problems.

I had clients reporting the following error with an Adobe Air / Flex application I wrote.

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032" errorID=2032]

This error is caused by a firewall blocking outgoing connections. See documentation for your firewall software as to how to fix. Here is a sample app I wrote to test network connections.

index.mxml

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" title="Networking Debug" creationComplete="init()">
   
<mx:Script source="scripting.as" />
   
<mx:VBox percentWidth="100" percentHeight="100">
       
<mx:TextArea percentWidth="100" percentHeight="100" editable="false" text="{this.log}" />
       
<mx:HBox percentWidth="100">
           
<mx:Button label="Start Test" click="runtest()" />
       
</mx:HBox>
   
</mx:VBox>
</mx:WindowedApplication>

scripting.as

import flash.events.Event;
import flash.events.SecurityErrorEvent;
import flash.events.IOErrorEvent;
import flash.events.HTTPStatusEvent;
import flash.events.ProgressEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;

protected var activeRequest:URLRequest = null;
protected var activeLoader:URLLoader = null;

[Bindable]
protected var log:String = "";

public function init():void
{
   
}

public function runtest():void
{
   
this.logThis("runtest()");
   
this.echoRequest("echo server test");
}

public function cleanup():void
{
   
this.logThis("cleanup()");
   
this.activeRequest = null;
   
this.activeLoader = null;
}

protected function echoRequest(value:String):void
{
   
this.logThis("echoRequest(" + value + ")");
   
   
var sendVars:URLVariables = new URLVariables();
   
sendVars.echo = value;
   
   
this.activeRequest = this.getRequest("http://google.com/echo", sendVars);
   
this.activeLoader = this.sendRequest(this.activeRequest);
}

protected function getRequest(url:String, vars:URLVariables):URLRequest
{
   
this.logThis("getRequest(" + url + ", URLVariables)");
   
   
var req:URLRequest = new URLRequest(url);
   
req.method = "GET";
   
req.data = vars;
   
   
return req;
}

protected function sendRequest(req:URLRequest):URLLoader
{
   
this.logThis("sendRequest(URLRequest)");
   
var load:URLLoader = new URLLoader(req);
   
   
with(load)
   
{
       
addEventListener(Event.OPEN, loadOpen);
       
addEventListener(Event.COMPLETE, loadComplete);
       
addEventListener(IOErrorEvent.IO_ERROR, loadIOError);
       
addEventListener(ProgressEvent.PROGRESS, loadProgress);
       
addEventListener(HTTPStatusEvent.HTTP_STATUS, loadStatus);
       
addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadSecurityError);
       
load(req);
   
}
   
return load;
}


protected function logThis(content:String):void
{
   
var now:Date = new Date();
   
this.log += now.toString() + ": " + content + "\n";
}

protected function loadOpen(e:Event):void
{
   
this.logThis("loadOpen(e)");
}

protected function loadComplete(e:Event):void
{
   
this.logThis("loadComplete(e)");
   
this.logThis("Loaded data bytes: " + this.activeLoader.bytesLoaded.toString() + "/" + this.activeLoader.bytesTotal.toString());
   
this.logThis("Loaded data length: " + this.activeLoader.data.length);
   
this.logThis("Loaded data content: " + this.activeLoader.data.toString());
}

protected function loadIOError(e:IOErrorEvent):void
{
   
this.logThis("loadIOError(e)");
   
this.logThis(e.toString());
}

protected function loadProgress(e:ProgressEvent):void
{
   
this.logThis("loadProgress(e)");
   
this.logThis(this.activeLoader.bytesLoaded.toString() + "/" + this.activeLoader.bytesTotal.toString());
}

protected function loadStatus(e:HTTPStatusEvent):void
{
   
this.logThis("loadStatus(e)");
   
this.logThis("status: " + e.status.toString());
   
}

protected function loadSecurityError(e:SecurityErrorEvent):void
{
   
this.logThis("loadSecurityError(e)");
   
this.logThis(e.toString());
}

Of course, I replaced the domain of my server with google.com. Test it like thus or on your own server.