HTTP keep-alive en node.js

Estoy tratando de configurar un cliente HTTP para mantener abierta la conexión subyacente (keep-alive) en node.js, pero parece que el comportamiento no corresponde a los documentos (http://nodejs.org/api/http.html#http_class_http_agent)

Estoy creando un nuevo agente HTTP, estableciendo la propiedad maxSockets en 1 y solicitando una url (por ejemplohttp://www.twilio.com/) cada segundo.

Parece que en cada solicitud se cierra el socket y se crea un nuevo socket. He probado esto con node.js 0.10.25 y 0.10.36 en Ubuntu 14.04.

¿Alguien ha podido mantenerse vivo para trabajar?

Aquí está el código:

var http = require("http");

var agent = new http.Agent();
agent.maxSockets = 1;

var sockets = [];

function request(hostname, path, callback) {
    var options = {
        hostname: hostname,
        path: path, 
        agent: agent, 
        headers: {"Connection": "keep-alive"}
    };
    var req = http.get(options, function(res) {
        res.setEncoding('utf8');
        var body = "";
        res.on('data', function (chunk) {
            body += chunk;
        });
        res.on('end', function () {
            callback(null, res, body);
        });
    });
    req.on('error', function(e) {
        return callback(error);
    });
    req.on("socket", function (socket) {
        if (sockets.indexOf(socket) === -1) {
            console.log("new socket created");
            sockets.push(socket);
            socket.on("close", function() {
                console.log("socket has been closed");
            });
        }
    });
}

function run() {
    request('www.twilio.com', '/', function (error, res, body) {
        setTimeout(run, 1000);
    });
}

run();

Respuestas a la pregunta(3)

Su respuesta a la pregunta