node.jsexpresshttpconnection

how to access http.Server.connection property in express 3 router?


I would like to use http.Server.connections in my express 3 route? Is there no way to get it anymore?

Should I just app.set('server', server);

express.createServer() is deprecated and express applications no longer inherit from http.Server

var app = express(),
server = http.createServer(app);
server.listen(8080);
...
module.exports = function (app) {

    app.get('/connections', function (req, res) {
        res.send({
            connections: app.connections 
            // app != http.Server in express 3
        });
    });

};

Solution

  • Instead of app.connections you need to send server.connections, since you've used:

    server = http.createServer(app);

    So your code becomes:

    app.get('/connections', function (req, res) {
        res.send({
            connections: server.connections 
        });
    });