title: Socket timeout on long POST node.js
body: <p>Using node.js <code>http.createServer</code> to listen POST requests. If request completes fast, all works good. If request complete time > 5 seconds i get no response returned to client.</p>
  
  <p>Added event listeners on created sockets:</p>
  
  <pre><code>server.on('connection', function(socket) {
      log.info('SOCKET OPENED' + JSON.stringify(socket.address()));
      socket.on('end', function() { 
        log.info('SOCKET END: other end of the socket sends a FIN packet');
      });
  
      socket.on('timeout', function() { 
        log.info('SOCKET TIMEOUT');
      });
  
      socket.on('error', function(error) { 
        log.info('SOCKET ERROR: ' + JSON.stringify(error));
      });
  
      socket.on('close', function(had_error) { 
        log.info('SOCKET CLOSED. IT WAS ERROR: ' + had_error);
      });
  });
  </code></pre>
  
  <p>Got those messages on middle of request (after about 10 sec after start):</p>
  
  <pre><code>info: SOCKET TIMEOUT
  info: SOCKET CLOSED. IT WAS ERROR: false
  </code></pre>
  
  <p>But on client socket do not get closed, so client wait for response. End of request completed with success, response sent (on closed socket!), but client still wait. </p>
  
  <p>No idea how to block those timeouts. Removed all timeouts from code. Tried to add KeepAlive, no result. </p>
  
  <pre><code>socket.setKeepAlive(true);
  </code></pre>
  
  <p>How to prevent socket bultin timeout?</p>