Question

I am instantiating and sending multiple instances of HTTPService On a Mac, however, many of the calls fail with a 2032 error.

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       click="windowedapplication1_clickHandler(event)"
                       creationComplete="windowedapplication1_creationCompleteHandler(event)">

    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.FlexEvent;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.http.HTTPService;

            [Bindable]
            private var r:int=0;
            [Bindable]
            private var f:int=0;

            private var a:Array= ['url1', 'url2', 'url3', 'url4', 'url5'];

            private var sa:Array=[];
            protected function windowedapplication1_clickHandler(event:MouseEvent):void
            {
                for(var i:int=0; i<sa.length; i++) {
                    sa[i].send();
                }

            }

            protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
            {
                for(var i:int=0; i<100; i++) {
                    var random:int=Math.floor(Math.random() * a.length);
                    var s:HTTPService=new HTTPService();
                    s.addEventListener(ResultEvent.RESULT, sr);
                    s.addEventListener(FaultEvent.FAULT, sf);
                    s.resultFormat="text";
                    s.url=a[random];
                    sa.push(s);
                }
                //s.useProxy=true;
            }

            private function sf(e:FaultEvent):void {
                f++;
                t.text="MESSAGE: " + e.message + "HEADERS:" + e.headers + "FAULTCONTENT: " + e.fault.content 
                    + "ERROR: " + e.fault.errorID + "|" + e.fault.faultCode + "|" + e.fault.faultDetail + "|" + e.fault.faultString
                    + "FAULTMESSAGE:" + e.fault.message + "FAULRNAME:" + e.fault.name + "ROOTCAUSE:" + e.fault.rootCause
                    + "AT " + e.fault.getStackTrace();
            }

            private function sr(e:ResultEvent):void {
                r++;
            }

        ]]>
    </fx:Script>

    <fx:Declarations>

    </fx:Declarations>
    <s:Label x="10" y="19" text="Result {r}"/>
    <s:Label x="10" y="120" text="Fault {f}"/>
    <s:TextArea x="10" y="198" width="610" height="294" id="t"/>
</s:WindowedApplication>

It works as expected on PC (I get all 100 results as successful) but on a Mac, I get wuite a few that fail. Why is this happening and how do I get around it?

Was it helpful?

Solution

It seems Win7 and Mac OS X block very quick requests to different addressed. Adding a 1 second timeout works fine

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top