URLLoader works randomly without causing errors or sending any events

In Adobe AIR 1.5, I use URLLoader to download videos in 1 MB fragments. It loads 1 MB, waits for the Event.COMPLETE event, and then downloads the next fragment. Server code knows how to create a video from these fragments.

It usually works fine. However, sometimes it just stops without any errors or sending any events. This is an example of what is shown in the log I am creating:

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 ...

etc...

Most of the time it completely fills all the pieces. However, sometimes it just fails in the middle:

Completed chunk 2 of 108
Uploading chunk of size: 1000000

... and nothing more, and no network activity.

, urlLoader.load(). , , load(), UIComponent callLaterDispatcher(), .

- , ? URLLoader :

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

. , , urlLoader.load() . , HTTP_RESPONSE_STATUS, HTTP_STATUS PROGRESS.

!

: , , , , .NET. .NET request.GetResponse() , . , , , . - , .

. URLLoader , . readAgain (.. ) ... , .

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;
}
+3
2

"Event.OPEN", , ? - , ?

[]

useCache false URLRequest?

[]

, urlLoader ... , , - GC ... - , "bytesTotal", " - - ?

[]

- URL- , - , , ( )...

+1

Flex, Safari. URL- , OPEN. , .

, , , https URL-. , Safari, .

0

Source: https://habr.com/ru/post/1709405/


All Articles