How to set the HTTP Keep-Alive timeout in a nodejs server

For Express 3:

var express = require('express');
var app = express();
var server = app.listen(5001);

server.on('connection', function(socket) {
  console.log("A new connection was made by a client.");
  socket.setTimeout(30 * 1000); 
  // 30 second timeout. Change this as you see fit.
});

To set keepAliveTimeout on the express server do:

var express = require('express');
var app = express();
var server = app.listen(5001);

server.keepAliveTimeout = 30000;