mgPePe
mgPePe

Reputation: 5907

AS3 ioError on some browsers only, why is that?

I am making a flash that calls google translate Text-to-speech service through the url:

translate.google.com/translate_tts?tl=en&q=example

I got it to work in firefox, but for some reason it does NOT work in chrome and safari. Where could be the problem?

the error I get is:

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://translate.google.com/translate_tts?tl=en&q=example"]

but when i copy/paste the URL in the browser, it returns a fil just like it should.

Flash players:

firefox: 10,0,42,34 installed - WORKS
chrome: 11,1,102,55 installed - DOES NOT WORK
safari: 10,0,42,34 installed - DOES NOT WORK

I am completely stunned. Don't know how to debug further.

Please help


UPDATE 1: FLASH CODE

    public function say(text:String, language:String):void {
        var urlString:String = createGoogleTTSUrl(text, language);
        var url:URLRequest = new URLRequest(urlString);
        //var context:SoundLoaderContext = new SoundLoaderContext(1000, true);
        _sound = new Sound();
        _sound.addEventListener(Event.COMPLETE, loadComplete);
        _sound.addEventListener(ErrorEvent.ERROR, err);
        _sound.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler2);
        _soundChannel = new SoundChannel();
        _sound.load(url); //, context);
    }
 private function ioErrorHandler2(event:IOErrorEvent):void {
        trace(event);
 }

I only later removed the SoundLoaderContext, but that didn't change anything.


UPDATE 2: Other people with same problem:

This tutorial has the same issue. Works in FF, but not in Chrome or Safari. People in comments reporting similar errors (click the demo button:) http://active.tutsplus.com/freebies/exclusive/exclusive-freebie-text-to-speech-utility/

Upvotes: 2

Views: 1443

Answers (1)

JimmiTh
JimmiTh

Reputation: 7449

The obvious reason for the #2032 error, when sniffing the actual request and response, is that Google is responding with a 404 when called from Flash in Chrome or IE (haven't tested Safari or Opera). But why does it return a 404?

Not a solution, but some troubleshooting - what does Firefox do differently from the others in terms of the request? In the following, ChD = "Chrome directly calling the API with no Flash (which works)"

Accept

FF: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Ch: Accept: */*

IE: Accept: */*

ChD: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

This might be it, but it seems unlikely. The two that work send more than just a wildcard Accept header.

User-Agent

Obviously each browser sends along different User-Agents. Except ChD sends the same as Ch - and the former works, so that isn't it.

Referer

Firefox sends no Referer along. The others send:

Referer: http://activetuts.s3.amazonaws.com/freebies/006_textToSpeech/tutorial/text2speech.swf

ChD obviously sends no Referer either, since I typed in the address manually. So the Referer header might be the problem.

Considering that TTS isn't a public API, but a private endpoint (for Google's own translate service), i.e. an endpoint which you're really not allowed to use, that wouldn't be surprising.

Other

Other than that, and some language acceptance details (+ cookie contents - the same set of cookies are sent - and on my machine, it's actually their own cookies for once - Flash used to have a problem where it sent cookies from IE in the Firefox plugin)... Other than that, the requests are identical, but only Firefox's doesn't result in a 404 on my machine.

FlashPlayer versions

FF: 11.0.1.152 Debug

Ch: 11.1.102.55

IE: 11.0.1.152 Debug

Update: IE also sends the Flash version along: x-flash-version: 11,0,1,152 - but none of the other browsers do, so that's not why they don't work.

Upvotes: 2

Related Questions