aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Multiple Concurrent AJAX Connecitons, HOWTO? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Multiple Concurrent AJAX Connecitons, HOWTO?" Watch "Multiple Concurrent AJAX Connecitons, HOWTO?" New topic
Author

Multiple Concurrent AJAX Connecitons, HOWTO?

Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
I would like to make as many concurrent connections as I need. I think I need a connection/object pool but I am not sure. I believe that I am only allow 2 connections at a time (correct?). I want to speed things up somehow. Currently I use this for loop to get all my required data...

Thanks,
Kevin C



[ November 09, 2005: Message edited by: Kevin Cornwell ]

[ November 09, 2005: Message edited by: Kevin Cornwell ]
[ November 09, 2005: Message edited by: Kevin Cornwell ]

<a href="http://www.kevincornwell.com" target="_blank" rel="nofollow">http://www.kevincornwell.com</A>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
In Ajax In Action we have an example project that preloads multiple RSS feeds into a reader. We use the Ajax loader to do this and it can handle multiple requests. I think IE is limited to 2 requests off the top of my head like you suggested.

I think Gecko browsers (Mozill and Firefox can handle a couple more).

A lot of the problems I see with people and doing multiple requests at the same time is using global variables to process the data. This in return will overwrite each other when the request is being sent/processed/etc.

Take a look at my blog at some of the posts (such as session timeout management) where I used a version of the ajax conent loader from Ajax In Action.

Eric
Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
Thanks for the response.

So tell me if I heard you correctly... There is no way to get more than 2 concurrent connections in IE?

I am checking out your sites now for more info. Is your book in the book stores yet? If so which?

Thanks,
Kevin C.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
On the website, there is a image of a globe that tells you where it is being sold.

http://www.manning.com/books/crane

For connectiosn I think it is 2-4 connections, I am trying to find my notes on this.

Eric
Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
Sweet. My local book store has it.
David C. Crane
author
Ranch Hand

Joined: Oct 13, 2005
Posts: 59
Hi Kevin,

The limit of 2 concurrent HTTP connections is a default for IE. It can be overridden by registry settings, but of course, you can only do that on your own test box. Other browsers are more permissive, as far as I know, IE is the only one with such a limit.

If you try to open more than two requests, it won't complain, it'll simply queue them, starting off #3 when #1 is done, etc.

I had a look through your code earlier today, it looks good. I was going to recommend that you use closures to match the XHR objects up with the callbacks, then realised that you were already doing so! This is one of the few situations where I'll recommend closures to everybody, there is no other way of finding out inside the callback which XHR is calling you back. The simple approach is to use a global XHR, but that won't scale to multiple concurrent requests. We provide examples of doinmg it both ways, using a global in chapter 2, then moving to closures in chapter 3 onwards.

Hope that helps,

Dave


---<br />Author of...<br />'Ajax in Action' <a href="http://manning.com/crane" target="_blank" rel="nofollow">http://manning.com/crane</a><br />'Prototype & Scriptaculous in Action'<br /><a href="http://manning.com/crane3" target="_blank" rel="nofollow">http://manning.com/crane3</a><br />'Ajax in Practice'<br /><a href="http://manning.com/crane2" target="_blank" rel="nofollow">http://manning.com/crane2</a>
Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
Thanks for the reply Dave.

Man, I've searched and searched for that registry setting. Where the heck is it?

Thanks again,
Kevin C
Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
:bump:
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I think this is it: http://support.microsoft.com/Default.aspx?kbid=282402

Eric
Christos Athanasiadis
Greenhorn

Joined: Dec 05, 2005
Posts: 1
http://www.digitaleyes.gr/AJAX/MR/ajax.php

If you think that's what you need simply e-mail me!
Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
Thanks for the response however your code will not create more than 2 concurrent connections. It's the same issue as disscussed above.

-Kevin C

PS-You do realize it is impossible to hide javascript from a client?
Sanjiv Jivan
Ranch Hand

Joined: Nov 03, 2005
Posts: 52
You might find this link useful. Apparently the two concurrent connection limit is part of the HTTP 1.1 spec and not a limitation.

http://support.microsoft.com/kb/183110

Sanjiv
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Originally posted by Sanjiv Jivan:
You might find this link useful. Apparently the two concurrent connection limit is part of the HTTP 1.1 spec and not a limitation.

http://support.microsoft.com/kb/183110

Sanjiv


Yes, BUT it is a limitation since you can not do more than two requests at a time.

Eric
Sanjiv Jivan
Ranch Hand

Joined: Nov 03, 2005
Posts: 52
I would say it is the limit of allowable concurrent requests but not a limitation (with IE). Limitation has the connotation of a shortcoming or defect.

Sanjiv
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Two connections is a shortcoming when you need 3.

Sorry, but I am just in one of those moods. LOL, it really is a play on words. One thing can mean a lot of things. How I take, means something different from you.

Eric
[ December 06, 2005: Message edited by: Eric Pascarello ]
Sanjiv Jivan
Ranch Hand

Joined: Nov 03, 2005
Posts: 52
Okay, fine
 
Consider Paul's rocket mass heater.
 
subject: Multiple Concurrent AJAX Connecitons, HOWTO?