Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Concurrent AJAX Connecitons, HOWTO?

 
Kevin Cornwell
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sweet. My local book store has it.
 
David C. Crane
author
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kevin Cornwell
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:bump:
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is it: http://support.microsoft.com/Default.aspx?kbid=282402

Eric
 
Christos Athanasiadis
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.digitaleyes.gr/AJAX/MR/ajax.php

If you think that's what you need simply e-mail me!
 
Kevin Cornwell
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic