PC Review


Reply
Thread Tools Rate Thread

AJAX simultaneous requests getting queued up

 
 
dmagliola@gmail.com
Guest
Posts: n/a
 
      29th Jan 2007
Hello all,

I'm experiencing a problem with ASP.Net for which I can't find a
reasonable explanation, or any information.


I'm currently developing an application that, through AJAX, asks the
server for updated information to show, and can also send information
to the server.
To do this, I have an XMLHttpRequest that queries an Asynchronous HTTP
Handler (implementing IHttpAsyncHandler), which does not reply until
there is actual information, or a time passes (30 seconds).
In order to send information to the server, I open a second
XMLHttpRequest and POST to another HTTP handler (this one is
synchronous).

Now, for this to work, both requests have to be simultaneous,
obviously, but what i'm getting is that the second request (the one
that POSTs) waits until the first one returns before sending, which
makes the app completely unresponsive.


Since I could think of a million things that could be going wrong here
(like the Asynchronous handler doing something weird), I created a
very simple test scenario to isolate the problem:

1) I created two synchronous (regular) HTTP handlers, that simply wait
for 5 seconds, and then reply with "OK-1" or "OK-2" (depending on
which one was queried).
2) In case I was forgetting something non-obvious (like implementing
some interface), I also tried creating these two as Pages, instead of
HTTP handlers, and I got exactly the same results.
3) I created a page which onLoad starts an XMLHttpRequest GET to the
first handler, and once it's finished, it calls the same function
again, creating a loop, which successfully outputs "OK-1" every 5
seconds.
4) I added a button that starts another XMLHttpRequest GET to the
second handler, only once (no loop)

This is where the problem lies. When I press the button, it seems like
requests are queued up. Once the first request comes back, after 5
seconds the second comes back, and then after another 5 seconds the
first one comes back again.

To make sure the problem wasn't on the client, I tried this with both
Firefox and IE, and I used 3 different ways of doing the Ajax call
(Prototype, AJAXRequest, and manually). I also tried both from
localhost, and from another computer in my network. All gave me the
same results.

Finally, if I implemented the 2 handlers on PHP (sorry for the
blasphemy), this worked exactly as expected, so this must be something
on the server, not on the client.

Also, it's not something about "the server not responding
simultaneously to two request from the same client" (which it
shouldn't anyway), since if I open 2 browser windows, the "loops" in
both work perfectly and simultaneously.

What I don't get is what difference there is between doing the two
requests from the same machine, and doing them from the same browser
window. Like I said, it works with PHP on the server, so i'm not
hitting the 2-connection limit on the client.

I'm seriously stumped on this one (and quite desperate, to be honest),
since if I can't fix this, the workaroung is looking PRETTY ugly
(aborting the pending request, creating the POST, then resuming the
loop, yuck...)

I assume this is some feature hiding somewhere inside ??.config, but i
can't find anything (i tried mindless things like setting debug=false,
trace=false, and other desperate attempts with no luck)

Any help, or pointers will be GREATLY appreciated!

Thanks in advance
Daniel Magliola

 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      29th Jan 2007
With ASP.NET (as well as with old ASP)
requests for the same session are queued up. Meaning that second will not
execute until first one is done.


so probably it's not problem with AJAX, you just need to specify that pages
you return information with are Session-less (or HttpHandlers in your case).


George



<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello all,
>
> I'm experiencing a problem with ASP.Net for which I can't find a
> reasonable explanation, or any information.
>
>
> I'm currently developing an application that, through AJAX, asks the
> server for updated information to show, and can also send information
> to the server.
> To do this, I have an XMLHttpRequest that queries an Asynchronous HTTP
> Handler (implementing IHttpAsyncHandler), which does not reply until
> there is actual information, or a time passes (30 seconds).
> In order to send information to the server, I open a second
> XMLHttpRequest and POST to another HTTP handler (this one is
> synchronous).
>
> Now, for this to work, both requests have to be simultaneous,
> obviously, but what i'm getting is that the second request (the one
> that POSTs) waits until the first one returns before sending, which
> makes the app completely unresponsive.
>
>
> Since I could think of a million things that could be going wrong here
> (like the Asynchronous handler doing something weird), I created a
> very simple test scenario to isolate the problem:
>
> 1) I created two synchronous (regular) HTTP handlers, that simply wait
> for 5 seconds, and then reply with "OK-1" or "OK-2" (depending on
> which one was queried).
> 2) In case I was forgetting something non-obvious (like implementing
> some interface), I also tried creating these two as Pages, instead of
> HTTP handlers, and I got exactly the same results.
> 3) I created a page which onLoad starts an XMLHttpRequest GET to the
> first handler, and once it's finished, it calls the same function
> again, creating a loop, which successfully outputs "OK-1" every 5
> seconds.
> 4) I added a button that starts another XMLHttpRequest GET to the
> second handler, only once (no loop)
>
> This is where the problem lies. When I press the button, it seems like
> requests are queued up. Once the first request comes back, after 5
> seconds the second comes back, and then after another 5 seconds the
> first one comes back again.
>
> To make sure the problem wasn't on the client, I tried this with both
> Firefox and IE, and I used 3 different ways of doing the Ajax call
> (Prototype, AJAXRequest, and manually). I also tried both from
> localhost, and from another computer in my network. All gave me the
> same results.
>
> Finally, if I implemented the 2 handlers on PHP (sorry for the
> blasphemy), this worked exactly as expected, so this must be something
> on the server, not on the client.
>
> Also, it's not something about "the server not responding
> simultaneously to two request from the same client" (which it
> shouldn't anyway), since if I open 2 browser windows, the "loops" in
> both work perfectly and simultaneously.
>
> What I don't get is what difference there is between doing the two
> requests from the same machine, and doing them from the same browser
> window. Like I said, it works with PHP on the server, so i'm not
> hitting the 2-connection limit on the client.
>
> I'm seriously stumped on this one (and quite desperate, to be honest),
> since if I can't fix this, the workaroung is looking PRETTY ugly
> (aborting the pending request, creating the POST, then resuming the
> loop, yuck...)
>
> I assume this is some feature hiding somewhere inside ??.config, but i
> can't find anything (i tried mindless things like setting debug=false,
> trace=false, and other desperate attempts with no luck)
>
> Any help, or pointers will be GREATLY appreciated!
>
> Thanks in advance
> Daniel Magliola
>



 
Reply With Quote
 
Daniel Magliola
Guest
Posts: n/a
 
      2nd Feb 2007
George,

Thank you for your resopnse.
I actually found the solution, and it was close to what you are saying
(I wish google groups would've let me know that you answered)

I was already implementing HttpHandlers, but they were not session-
less. In fact, i DO need sessions.
What I ended up doing was implementing IReadonlySessionState in these,
so they could access session but wouldn't be blocking it.

Thanks again for the help!

Daniel Magliola

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report NON enterprise edition: simultaneous user requests siddharthkhare@hotmail.com Microsoft C# .NET 0 17th Jan 2009 09:15 PM
ASP PerfMon Excessive Requests Queued Matt Jensen Microsoft ASP .NET 1 14th Dec 2005 04:17 PM
Web Service requests are being queued...why? =?Utf-8?B?TGFycnkgRA==?= Microsoft Dot NET 0 26th Jul 2005 07:51 PM
ASP.NET Requests Queued and IIS Restarting Chris Goodwin Microsoft ASP .NET 3 26th Mar 2004 10:01 AM
ASP.NET Requests Queued Vani Microsoft Dot NET Framework 3 13th Nov 2003 08:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:02 AM.