Multiple URLRequest's problem

Subscribe to Multiple URLRequest's problem 6 posts

avatar for DPbrad DPbrad 1197 posts
Flag Post

Has anybody ever had issues with URLRequest’s unexpectedly failing or stopping for no good reason?

I have a series of functions all getting data (Mainly JSON and XML files) and 90% of the time Flash will load all the files fine, however sometimes it will just stop after a certain amount.

My code;

function loadXSI(xsiSuffix:String, complete:Function):void

var url:String = "XXXXXXX" + xsiSuffix
_callbacks["loadXSInformation"] = complete;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXSIComplete, false, 0, true);
var request:URLRequest = new URLRequest(url);
loader.load(request);
if (_updateFeed) _updateFeed.text = "Requesting XS Information...";

That function gets called multiple times like so;


for(var a:int=0;a<EntityList.userLength;++a){
	loadXSI("user="+String(a+1),xsiComplete);
}

However when I add a counter into the xsiComplete() function (to see how many of the requests are complete, sometimes it will just “hang” on say number 42/50 or so.

Is there any way to fix this or to detect when the request has been hanging (or failed)?

 
avatar for UnknownGuardian UnknownGuardian 8142 posts
Flag Post

Add events to catch errors and check progress. ProgressEvent.PROGRESS, IOErrorEvent.IO_ERROR, And it might be worth loading your app in the browser and seeing in the Dev Tools panel if there are any issues.

 
avatar for DPbrad DPbrad 1197 posts
Flag Post

Ok thanks UG. I tested it in on my server and it hasn’t frozen yet (Tested ~50 times) so might be some weird local debug FlashDevelop issue?

 
avatar for DPbrad DPbrad 1197 posts
Flag Post

After further testing, it still does freeze occasionally, and testing with the ProgressEvent.PROGRESS event listener, the bytesLoaded just stops increasing, and no IOErrorEvent.IO_ERROR ever triggers, so im a little preplexed about what is happening. Will keep plugging away at figuring out what is wrong and will post an update if I figure it out.

 
avatar for BobJanova BobJanova 859 posts
Flag Post

Sometimes web requests just drop out. That’s true in a browser as well as when using an API. You need to code around it.

 
avatar for DPbrad DPbrad 1197 posts
Flag Post

Yeah, I have kind of given up trying to solve it, as you say, I am just putting a little internal timer that fires if the bytesLoaded value hasn’t changed for more than a few seconds, then retry the web request.