Search code examples
actionscript-3apache-flexairadobemacos-sierra

Emerging Stream Error #2032 in Adobe AIR application on Mac OS Sierra, help needed


I'm trying to help out a client with an Adobe AIR application that suddenly stopped working on Mac OS Sierra. I haven't developed the app myself, so I am trying to do my best to solve the problem. It's essentially a Flex application written in Actionscript 3. When I was debugging I can see that I am getting the following error:

[ERROR] Error #2032: Stream Error.

The way the application works is that it first makes a web request to the server and gets an XML with a number of songs. No problem there.

After that the application downloads the first song in the XML result and starts playing.

When the first song starts playing the application then downloads the second song in the XML-list, when that download is finished it starts downloading the next one and so forth. The files being downloaded seems to be rather large, a couple of MB's.

So the first download works just fine, but all the other track downloads fails with Stream Error #2032. It seems I dont get any response headers from the failed requests, only the first one. I have a crossdomain.xml on the server.

This app works just fine on Mac OS X El Capitan and Windows, but with Sierra I am getting this error. The code is not that complex, it makes an API URL Request with an URLLoader and saves the file to disk. I have also tried using URLStream instead, same issue.

This is some of the code for example:

    public function downloadTrack(track:Object, storeName:String, apiKey:String):void {

        this.setCurrentTrack(track);

        this.urlParameters.storeName = storeName;
        this.urlParameters.keystring = apiKey;

        this.urlLoader = new URLLoader();
        this.urlLoader.dataFormat = URLLoaderDataFormat.BINARY;

        this.urlRequest = new URLRequest("/api/" + 'download/' + 
        this.currentTrack.id + "?time=" + new Date().getTime());
        this.urlRequest.method = URLRequestMethod.POST;
        this.urlRequest.data = this.urlParameters;

        this.addEventListeners();

        this.urlLoader.load(this.urlRequest);

    }

    private function loaded(e:Event):void {
        this.fileData = e.target.data;
        writeFile();
    }

    private function writeFile():void {
        var filePath:String = this.currentTrack.md5 + '.ogg';
        var cacheFile:File = this.downloadDirectory.resolvePath('.' + filePath);

        this.fileStream.addEventListener(Event.CLOSE, saveReady);
        this.fileStream.openAsync(cacheFile, FileMode.WRITE);
        this.fileStream.writeBytes(fileData,0,fileData.length);
        this.fileStream.close();
    }

In the addEventListeners()-method, event-listeners for the URLLoader is added, and it's the urlloader that fires the IOError.

A weird thing that has happened twice is that the app suddenly starts to work as normal and downloads all of the files successively. Then after a couple of minutes it starts acting up again and nothing works. I am really having a hard time to understand where the error lies. I am no Adobe AIR/Flex-expert, so maybe you can point me in the right direction? I am pretty close to giving up on this one.

Thanks!


Solution

    • Try to change the destination, probably you don't have permissions to write there.
    • Use the latest AIR SDK

    Would be much better if you will share the project where it reproduced so I could check on my machine