Note that there are some explanatory texts on larger screens.

plurals
  1. POURLLoader fails randomly without throwing an error or dispatching any events
    primarykey
    data
    text
    <p>In Adobe AIR 1.5, I'm using URLLoader to upload a video in 1 MB chunks. It uploads 1 MB, waits for the Event.COMPLETE event, and then uploads the next chunk. The server-side code knows how to construct the video from these chunks.</p> <p>Usually, it works fine. However, sometimes it just stops without throwing any errors or dispatching any events. This is an example of what is shown in a log that I create:</p> <pre><code>Uploading chunk of size: 1000000 HTTP_RESPONSE_STATUS dispatched: 200 HTTP_STATUS dispatched: 200 Completed chunk 1 of 108 Uploading chunk of size: 1000000 HTTP_RESPONSE_STATUS ... </code></pre> <p>etc...</p> <p>Most of the time, it completes all of the chunks fine. However, sometimes, it just fails in the middle: </p> <pre><code>Completed chunk 2 of 108 Uploading chunk of size: 1000000 </code></pre> <p>... and nothing else, and no network activity.</p> <p>Through debugging, I can tell that it does successfully call urlLoader.load(). When it fails, it just seems to stall, calling load(), and then calling the UIComponent's callLaterDispatcher() and then nothing.</p> <p>Does anyone have any idea why this could be happening? I'm setting up my URLLoader like this:</p> <pre><code>urlLoader.dataFormat = URLLoaderDataFormat.BINARY; urlLoader.addEventListener(Event.COMPLETE, chunkComplete); urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); urlLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, responseStatusHandler); urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, statusHandler); urlLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler); </code></pre> <p>And I'm re-using it for each chunk. No events get called when it doesn't succeed, and urlLoader.load() doesn't throw any exceptions. When it succeeds, HTTP_RESPONSE_STATUS, HTTP_STATUS, and PROGRESS events are dispatched.</p> <p>Thanks!</p> <p>Edit: One thing that might be helpful is that, we have the same upload functionality implemented in .NET. In .NET, the request.GetResponse() method sometimes throws an exception, complaining that the connection was closed unexpectedly. We catch the exception if this happens, and try that chunk again, until it succeeds. I'm looking to implement something similar here, but there are no exceptions being thrown or error events being dispatched.</p> <p>More detailed code example below. The URLLoader is setup as described above. The readAgain variable just makes it skip reading a new set of bytes in the file stream (ie: it tries to send the old one again) ... however, it never catches any exceptions, because none are ever thrown.</p> <pre><code>private function uploadSegment():void { .... prepare byte array, setup url ... // Create a URL request var urlRequest:URLRequest = new URLRequest(); urlRequest.url = _url + "?" + paramStr; urlRequest.method = URLRequestMethod.POST; urlRequest.data = byteArray; urlRequest.useCache = false; urlRequest.requestHeaders.push(new URLRequestHeader('Cache-Control', 'no-cache')); try { urlLoader.load(urlRequest); } catch (e:Error) { Logger.error("Failed to upload chunk. Caught exception. Trying again."); readAgain = true; uploadSegment(); return; } readAgain = false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload