Multiple URLRequest's problem

6 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);
if (_updateFeed) _updateFeed.text = "Requesting XS Information...";

That function gets called multiple times like so;

for(var a:int=0;a<EntityList.userLength;++a){

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)?

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.

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?

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.

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.

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.