0

I'am in a project where i need to establish the most possible http connections and keep them open for nat port testing, using node.js but I'm not sure how I could do it, till now i got this:

var http = require('http');
var http_options = {
    hostname: '193.136.212.161',
    port: 80,
    path: '/',
    method: 'GET',
    agent: false,
    headers: {
       'Connection':'keep-alive'
    }
};

var req = http.request(http_options)
  .on("socket", function (socket) {
      console.log('got connected!');
   });
req.end();

unfortunely it closes the connection not keeping it alive, if i could have some tips to advance would be great.

Nuno Barros
  • 101
  • 2
  • 11
  • It's not keeping it alive because you are ending the connection after just logging the text. – Andrew Barber May 22 '14 at 15:24
  • yh I notice that but even if I remove it, wasn't I supposed to see some packets probing the connection? – Nuno Barros May 22 '14 at 15:51
  • 1
    What do you mean by 'packets probing the connection'? Nothing would be sent if you don't explicitly do so. Incidentally, you could also use telnet to do this testing; a telnet server listening on port 80, and telnet clients connecting to it through the NAT. Then just send data through them periodically. That may or may not be easier than this. – Andrew Barber May 22 '14 at 15:54
  • i thought that by keeping the connection alive it would send a packet at some interval of time, must have been reading the wrong information about it – Nuno Barros May 22 '14 at 16:26

0 Answers0