Skip navigation
Currently Being Moderated

Multiple HTTP requests using single HTTPService component

May 18, 2010 12:03 AM

Hi,

 

I am having one requirement, I need to use a single HTTPService component to send request to a same and single ASP.net multiple times.

 

How can I acheive that..? I know that I can acheive this by sending one request at a time and after the "result" event is called for the first request then sending the second request and so on...

 

But if I do so then it will be delayed response as I need to wait until the result handler for the previous request is called...

 

So how do I do this..?

 

Any help greatly appreciated....:)

 

 

Thanks in advance..

 

Thanks,

Bhasker Chari

 
Replies
  • Currently Being Moderated
    May 18, 2010 11:37 AM   in reply to BhaskerChari

    Why would waiting for the response handler be too long ?  Not to mention , Flex can only have 2 connections to the same ip address I assume any attempted connections over the browser-enforced-limits will just get queued up.  If you have BlazeDS you could set up a polling-service and use the Consumer/Producers in Flex/AS3 , that sounds more like what you are trying to do.

     
    |
    Mark as:
  • Currently Being Moderated
    Calculating status...
    May 18, 2010 3:02 PM   in reply to BhaskerChari

    It's possible to send mutliple requests simultaneously with a single HTTPService instance. There is a "concurrency" property which is set to "multiple" by default.

     

    If you do this, you need to work out a way to manage the result events so you can distinguish which result corresponds to which call. There are probably many ways to do this, depending on your needs. One way is to set properties on the AsyncToken that is returned from the HTTPService.send() method. The AsyncToken is a dynamic object so you can set your own additional properties on it. For example, you could set a "callback" property that points to a Function to call when the service call returns. You can retrieve the AsyncToken from the ResultEvent.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 11, 2010 11:19 AM   in reply to BhaskerChari

    Hi,

     

    As ubuntu said, even if you have multiple Http or remote services, the browser will open only 2 connections at a time.  If you are calling a service 5 times, the calls get queued.  Flex will wait for the result of all the services.

     

    I assume that your problem is to avoid the delayed response. Even I had the same problem and we used multiple channels to resolve the issue. I hope the follwoing link migh help you.

     

    http://cookbooks.adobe.com/post_Performance_tip__Use_multiple_duplicat ed_remote_ob-10663.html

     

    Thanks & Regards

    mxvx

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 11, 2010 3:32 PM   in reply to mxvx

    I wasn't aware of the 2 connections limit, but does that only apply to HTTPService when setting a destination?

     

    Here I have useProxy set to false and set the url of the HTTPService directly. On a Mac with Safari as the browser, I send 5 HTTPService requests in sequence to the same url. Monitoring the traffic with tcpdump, all five request are sent before any response is received.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2010 2:45 AM   in reply to dave cragg

    I'm researching this too. Dave, please post what you find. My understanding is IE was deficient (old design requirements) on this. IE6 limited to 2. IE7 more. (5?). and IE8 configurable but defaults to 6.

     

    I am not sure about HTTPService. Does it run through the browser or open its own sockets? If it is truly limited to 2 is this for IE6 but more for FF, IE8?

     

    Also, for an embedded Flash app, does the HTTPService then interfere with the AJAX calls?

     

    We planned to use Flex (Flash) instead of an applet but perhaps we've made a grave error here.

     

     

    Does anyone know how this works?

     

    TIA,

    Tim Jowers

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2010 3:58 AM   in reply to timjowersboa

    Its ugly. IE8 limits to 6.

    Using multiple HTTPService instances does not help.

    HTTPService does work through teh browser and is controlled by the browser setting.

     

    We hate to fall on our sword but looks like an applet might be back on the table. This one hurts bad. With friends like this...

     

     

    Ok, so now off to test the setting for IE8.

    http://www.tech-recipes.com/rx/4140/ie8-increase-the-maximum-connectio ns-limit-to-download-more-than-six-files-at-one-time/

    As it the MaxConnectionsPerServer instructions from another page did not work and must have been for IE6 or so.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2010 4:16 AM   in reply to timjowersboa

    yep, the setting works when set to 10. Seemed to not work when set to 20. Anyways, summary is "long polling" and Flex

    or Flash are not good compatriates. So, you will need to work out your own mechanism on the server or client

    side to limit the sockets used/wasted. Painful but true.

     

     

    <?xml version="1.0" encoding="utf-8"?>

    <mx:Application

     

     

    xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>

    <![CDATA[

     

     

    import com.util.HTTPServiceProxy;

     

    import mx.rpc.events.FaultEvent;

     

    import mx.rpc.events.ResultEvent;

     

    import mx.rpc.http.HTTPService;

     

     

    private var urlOpenTasksDefault:String = HTTPServiceProxy.servercontext + "/blahblah?something=somethign";

     

    private var waitRequestPart:String = "&wait=5000&lastUpdate=" // long polling period for now for testing

     

     

    private var iResponses:int;

     

     

    private function runTest(urlString:String):void{

     

    var service:HTTPService = new HTTPService();

    service.url= urlString;

    service.resultFormat =

    "e4x";

    service.method =

    "get";

    service.contentType=

    "application/xml";

    service.addEventListener(

    "result", httpResult);

    service.addEventListener(

    "fault", httpFault);

    service.send();

    }

     

     

    public function httpResult(event:ResultEvent):void {

     

    trace("httpResult " + iResponses++ );

    }

     

    public function httpFault(event:FaultEvent):void {

     

    trace("httpFault " + (iResponses++) + event.fault.faultString);

    }

     

     

    private function test1(evt:Event):void {

    iResponses=0;

     

    var reqs:int = parseInt(requests.text);

     

    for( var i:int=0; i<reqs; i++ ){

    runTest(urlOpenTasksDefault);

    }

    }

     

    private function test2(evt:Event):void {

    iResponses=0;

     

    var reqs:int = parseInt(requests.text);

     

    for( var i:int=0; i<reqs; i++ ){

    runTest(urlOpenTasksDefault+waitRequestPart+

    "0");

    }

    }

    ]]>

    </mx:Script>

     

     

    <mx:Label text="Requests"/>

     

    <mx:TextInput id="requests"/>

     

    <mx:Button label="Test Requests-Responses" click="test1(event)"/>

     

    <mx:Button label="Test Long Polling" click="test2(event)"/>

    </mx:Application>

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2010 6:06 AM   in reply to timjowersboa

    Does AMF (RemoteObject, BlazeDS) also suffer this restriction?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2010 5:36 AM   in reply to timjowersboa

    yes also AMF is suffering this resitriction, even AIR

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points