in ajax, node can only take up to 6 requests if no response is set during 
that time.

see the code:

on the server:

var http = require('http');
http.createServer(onResponse).listen(9999);

function onResponse(req, res){
    console.log('req received');
    setTimeout(function(){
         res.writeHead(200);
         res.end("console.log('response sent')");
    },6000);
}


on the client (using jquery and jsonp):

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.jsonp-2.2.0.min.js"></script>
<body>
<button id="boton">click me</button>
<script type="text/javascript">
$('#boton').click(function(){
    $.jsonp({
      url: 'http://localhost:9999',
      callback: function(){},
      data: {key1:'key1v',key2:'key2v'},
      timeout: 50000,
      success: function(){
       console.log('success');
      },
      beforeSend: function(){console.log('fire!');}
    });
  });
</script>
</body>


As you can see:

   - each time the button is clicked, a jsonp request is made to the 
   server. a log line of "fire!" is printed on browser console just before 
   sending the request.
   - each time the server receives a request, it takes 6 seconds to send 
   back the response. a log line of "req received" is printed at the server's 
   console upon req reception. a log line of "response sent" is printed at the 
   server's console upon response sending
   - a log line of 'success' is printed at the browser's console upon 
   response reception.


if I make, say 10 6 clicks in less than 6 seconds I will only see 6 "req 
received" log lines. I will see 10 "fire!" loglines in the browser console 
and of course no "response sent" or "success" logline whatsoever (because 6 
seconds hasn't passed yet).

After the 6 seconds, the pending requests (4) comes in, and I see the 4 
remaining "req received" loglines . 


I guess its standard behavior, I just didn't know, I don't know if this can 
be worked around somehow, or I'm just missing something.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to