0

I'm attempting to load ads in a Flash video player then download all of the 1x1 Impression gifs linked in the VAST file. Everything works well until I hit this file:

link to bad file

This file returns status code 302 (moved temporarily) with a Location header pointing to http://httpstat.us/503 -- a very strange way of returning a 503 error

When this happens I receive an error #2030 in Flash: "End of file was encountered."

Looking at http://httpstat.us/503, the Content-Length is 23 and exactly matches the length of the returned text ("503 Service Unavailable"), so I don't believe it's a problem with the server response.

In my Flash file I have bound listeners to both SecurityError and IOError events:

    loader.addEventListener(Event.OPEN, onOpen);
    loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onStatus);
    loader.addEventListener(ProgressEvent.PROGRESS, onProgress);
    loader.addEventListener(Event.COMPLETE, onComplete);

    loader.addEventListener(IOErrorEvent.IO_ERROR, onError);
    loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);

    loader.load(request);

So my question is: What am I doing wrong? How am I supposed to detect and handle status code 503 in Flash?

stevendesu
  • 15,753
  • 22
  • 105
  • 182
  • I have standard _Error #2032: Stream Error._ for that url – fsbmain Sep 03 '14 at 15:58
  • @fsbmain That's bizarre... I have a global uncaught error handler which simply logs the time and the error ID, and it posts "12:08:29 PM -- CRASH DETECTED -- Error: #2030". The stack trace is just two lines: "flash.net.URLLoader.onComplete" followed by "flash.net.URLStream.readBytes" – stevendesu Sep 03 '14 at 16:09
  • @fsbmain I just did some more tests and found that when I open the SWF locally (file://C:\...) I get error #2032. It's when I open it online (http://...) that I get error #2030. So it may be Flash Sandbox related. – stevendesu Sep 03 '14 at 16:28

1 Answers1

1

After experimenting with this I found it's a bug in Flash Player -- when you receive a 302 the Flash Player secretly spins up a new URLLoader to handle the second request, but maps all of the events and function calls. Because it is a separate object, any errors that are thrown will not be caught.

My solution was to add a global, static counter for 503 errors then have an uncaught error handler.

  1. Receive a 503 error, increment the counter
  2. Receive an uncaught error, check counter:
    • If error ID is 2030 AND counter > 0, decrement counter
    • Else, throw the error
stevendesu
  • 15,753
  • 22
  • 105
  • 182