Answer the question
In order to leave comments, you need to log in
How to count number of node.js connections?
Good afternoon!
There is a small project on node.js + express, I can't figure out how to count the number of active connections at the moment.
Those. a function that, when called, yields a specified number of connections.
I will be glad to help.
Answer the question
In order to leave comments, you need to log in
var count = 0;
var app = express();
http.createServer(app).listen(8080)
.on('connection', function(socket) {
count++;
socket.on('close', function () {
count--;
})
});
function getConnectionsCount () {
return count;
}
var app = express();
var server = http.createServer(app).listen(8080);
server.getConnections(function (err, count) {
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question