title: setting node's http.request timeout
body: <p>I'm testing a server and I need to keep alive some connection as long as possible. I would like to set by hand the timeout of <code>http.request()</code> function. This is what I do in my code.</p>
  
  <pre><code>var req = http.request(options, function(res) {
          res.setEncoding('utf8');
  
          res.on('data', function (chunk) {
              //do something with chunk
          });
  });
  </code></pre>
  
  <p>I tried something like <code>req.on('socket' function(socket){ socket.setTimeout(SOCKET_TIMEOUT);  });</code> but it gives me some strange errors and I think it's not the right way to do it. For your info the error I get using that approach is the following</p>
  
  <pre><code>Trace: 
      at Socket.&lt;anonymous&gt; (events.js:133:17)
      at ClientRequest.&lt;anonymous&gt; (/path/server_nologs.js:168:10)
      at ClientRequest.emit (events.js:88:20)
      at Array.1 (http.js:1250:9)
      at EventEmitter._tickCallback (node.js:192:40)
  (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
  </code></pre>
  
  <p>Which is kinda cryptic to me. Can someone explain me how to set the timeout? Otherwise, if my approach is correct, how can I avoid getting that error?</p>