I have a simple Node.js script that starts a HTTP server on port 1337 and handles GET requests. I send 10 GET requests (in less than a second) to localhost:1337/?number=(number from 1 to 10). The script handles the first 6 requests, then takes a 2 minute break, then handles the 4 remaining requests.
I need to handle the HTTP GET requests immediately when they are sent. How would I do that?
Here is my code:
var url = require('url'),
   http = require('http'),
     qs = require('querystring');
var server = http.createServer(function (request, response) {
  if (request.method == 'GET') {
    var url_params = url.parse(request.url, true);
    var number     = url_params.query.number;
    console.log(number);
  }               
});
server.listen(1337);
				
				It's most likely because you never close the connection. Try adding a res.end() call.
Try to add the following lines at the end of the request handler:
res.writeHead(200);
res.end();