I'm basically doing a post to a webserver in my local lan and it works 
perfectly until the server resets etc and then my code fires the IOErrorEvent 
from my listener and as this routine is on a timer (set for 30 seconds) it runs 
through the code again after 30 seconds and falls into a try catch and stays 
this way until the app is restarted. The server is sometimes glitches for a 
minutes and it's back on, i can test it with another app i have and it's 
responding just fine so i know it's in the as code. When i run through the 
routine and use what's below.

My question is what happens to the url loader etc after a failed ioerror. I've 
noticed this error is different if i unplug the server from the lan i get an 
ioerror and when i plug it back in then it continues to work fine, it's when 
the server is running and does/sends something different but i get the stream 
error in the ioerror listener This error.. but it's the same as the error for 
disconnecting the server cat5 line. This error is what gets repeated over and 
over based on the 30 second time. Like i said if i restart the app then it 
works fine again.

It appears that the server is sending somthing back other than 20* commands, so 
what happens to flex after then occurs and it will create a "new" loader and 
request but will not send it after the error even though the server is ready 
for the requests. after some searching it appears this is a big issue and I'm 
looked at a site with this 
http://code.google.com/p/as3httpclientlib/wiki/Examples ,
but i'm getting somewhat tired of using 3rd party stuff to get where i'm trying 
to go in flex. '' already using assql and another to unzip files etc.. 

Please Help !

ioErrorHandler: [IOErrorEvent type="ioError" bubbles=false cancelable=false 
eventPhase=2 text="Error #2032: Stream Error. URL: http://192.168.0.105/rpc"; 
errorID=2032] datetime: 2009-05-09 14:32:32






loader = new URLLoader();
request = new URLRequest("http://"; + boxip.text + "/rpc");

it seems these are goofed up as I can do a watch on the loader and it's got 
it's basic info no different that when it's succesful as is the request.

Here's my code.

above it snippets from .as file

public var what_run:String = "";
public var what_run_number:int;

private var loader:URLLoader;
private var obj:MyObject;
private var what_to_send:String;
private var header:URLRequestHeader;
private var request:URLRequest;
private var header2:URLRequestHeader;


private function CallWebService(whattorun:String):void
{

what_run = whattorun; //global variable solar plant name.

loader = new URLLoader();
obj = new MyObject;
header = new URLRequestHeader("Content-Type", "application/json");
header2 = new URLRequestHeader("pragma", "no-cache");

//clear all the text boxes
output_txt2.text = "";
misc.text = "";

configureListeners(loader);

request = new URLRequest("http://"; + boxip.text + "/rpc");
request.requestHeaders.push(header);
request.requestHeaders.push(header2);
request.method = URLRequestMethod.POST;


var okhere:String = "n";


obj.version = "1.0";
obj.proc = "GetPlantOverview";
obj.id = "1";
obj.format = "JSON";
okhere = "y";
request.data = 'RPC='+JSON.encode(obj);
test.text = JSON.encode(obj);



trace("Sending: " + request.data);

loader.dataFormat = URLLoaderDataFormat.TEXT;



try {
loader.load(request);

} catch (error:Error) {
deleteListeners(loader);
try {
loader.close();
} catch (e:Error) {
trace('Loader manually closed.');
}

trace('Unable to user loader.');
}



private function completeHandler(event:Event):void
{



//var loader:URLLoader = URLLoader(event.target);

loader = URLLoader(event.target);

deleteListeners(loader);



//send recieved data to the text area.
output_txt.text = loader.data;

//ok let's work with the strings.

var jsonstring:String = loader.data;

DO Processing here..

}




private function configureListeners(dispatcher:IEventDispatcher):vo id
{
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, 
securityErrorHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_S TATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}

private function deleteListeners(dispatcher:IEventDispatcher):void
{
dispatcher.removeEventListener(Event.COMPLETE, completeHandler);
dispatcher.removeEventListener(SecurityErrorEvent. SECURITY_ERROR, 
securityErrorHandler);
dispatcher.removeEventListener(HTTPStatusEvent.HTT P_STATUS, httpStatusHandler);
dispatcher.removeEventListener(IOErrorEvent.IO_ERR OR, ioErrorHandler);

}










private function securityErrorHandler(event:SecurityErrorEvent):voi d
{
pac_text.text = "0";
output_txt.text = "securityErrorHandler: " + event;

}

private function httpStatusHandler(event:HTTPStatusEvent):void
{
output_txt.text = "httpStatusHandler: " + event;

}

private function ioErrorHandler(event:IOErrorEvent):void
{

trace("ioErrorHandler: " + event);



}

Reply via email to