Skip to main content

javascript - Multiple Ajax Requests to Node.js timing out -


i have unique setup, imagine having effect on issue (which i've never seen before).

i'm writing google chrome extension, , i'm relying on node.js backend.

when run multiple ajax requests, , node.js takes long time respond (for instance, 2.5 seconds) of ajax requests never receive response , throw error.

i've set test function in node.js server respond json object after waiting 2500 ms. i've confirmed works single request.

then, i've tried embedding jquery in extension , trying 2 requests:

 (function(){ $.ajax({ url : url, data : params, type : "post", success : function(data){ alert('success1'); }, error : function(xmlhttprequest, textstatus, message) { alert('error'); } }); })(); (function(){ $.ajax({ url : url, data : params, type : "post", success : function(data){ alert('success2'); }, error : function(xmlhttprequest, textstatus, message) { alert('error'); } }); })(); 

in case, second alert called. first 1 result in error (timeout).

i tried without jquery, so:

 var xhr = new xmlhttprequest(); xhr.open("post", url, true); xhr.onreadystatechange = function() { alert('response1'); } xhr.send(); var xhr2 = new xmlhttprequest(); xhr2.open("post", url, true); xhr2.onreadystatechange = function() { alert('response2'); } xhr2.send(); 

in case, both of requests fail; don't receive response either one.

i've tried code in background script, running on auto generated background page. fails (neither success works).

i'm guessing related in way niche case i'm writing here, @ point i'm @ standpoint how troubleshoot , move forward. ideas exploring issue further?

thanks! kevin

javascript - multiple ajax requests node.js timing out - stack overflow

learn, share, build

each month, on 50 million developers come stack overflow learn, share knowledge, , build careers.

join world’s largest developer community.

sign up

i have unique setup, imagine having effect on issue (which i've never seen before).

i'm writing google chrome extension, , i'm relying on node.js backend.

when run multiple ajax requests, , node.js takes long time respond (for instance, 2.5 seconds) of ajax requests never receive response , throw error.

i've set test function in node.js server respond json object after waiting 2500 ms. i've confirmed works single request.

then, i've tried embedding jquery in extension , trying 2 requests:

 (function(){ $.ajax({ url : url, data : params, type : "post", success : function(data){ alert('success1'); }, error : function(xmlhttprequest, textstatus, message) { alert('error'); } }); })(); (function(){ $.ajax({ url : url, data : params, type : "post", success : function(data){ alert('success2'); }, error : function(xmlhttprequest, textstatus, message) { alert('error'); } }); })(); 

in case, second alert called. first 1 result in error (timeout).

i tried without jquery, so:

 var xhr = new xmlhttprequest(); xhr.open("post", url, true); xhr.onreadystatechange = function() { alert('response1'); } xhr.send(); var xhr2 = new xmlhttprequest(); xhr2.open("post", url, true); xhr2.onreadystatechange = function() { alert('response2'); } xhr2.send(); 

in case, both of requests fail; don't receive response either one.

i've tried code in background script, running on auto generated background page. fails (neither success works).

i'm guessing related in way niche case i'm writing here, @ point i'm @ standpoint how troubleshoot , move forward. ideas exploring issue further?

thanks! kevin

share|improve question
    
so set server wait 2.5 seconds before responding, , know why takes 2.5 seconds respond? – orangedog jul 7 '12 @ 15:44
    
checked requests with? chrome developer tools (net tab, etc.)? show use server code? what's unique or niche making using jquery call node server? – orangedog jul 7 '12 @ 15:45
    
it's possible you're running against browser-imposed limit on number of pending connections single server (the http 1.1 standard recommends two). – ebohlman jul 7 '12 @ 21:44

your answer

 
discard

posting answer, agree privacy policy , terms of service.

browse other questions tagged or ask own question.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -