Check active connections on Server


I’m looking at the methods on Server Connections | Meteor API Docs.

Looks like they’re all for client code though.
i.e. Meteor.getStatus() only gets info about 1 client<->server connection, I want to be able to see all active ones.

I want the server to be able to list all active connections.

Is this possible? Thanks!

Edit: I just found out about Meteor.default_server.stream_server.all_sockets().length through javascript - meteor currently active users? - Stack Overflow .

Haven’t tested it yet but will attempt to see if it works for me.

Edit: Looks like both Meteor.server.stream_server.open_sockets and Meteor.default_server.stream_server.open_sockets return an array of SockJSConnections
Does anybody know if there’s a difference?

It seems like this works in Chrome server debugger, but I keep getting [] when trying to console log in actual server code in Meteor.startup() (I guess this makes sense)

Anyways, my use case is to detect amount of current open connections prior to running a cron job with SyncedCron. So I’ll put this code there and see if it works.

Hi, i’m on METEOR@2.5.1 and Meteor.server.stream_server.all_sockets() works.


I’ve always been using netstat | grep https and netstat | grep https | wc -l to get a count of all https connections, didn’t know about this stream_server.all_sockets() thanks for sharing

1 Like

Seems like all_sockets and open_sockets do the same thing. Happen to know if there’s a difference?

You’re executing that from JS code itself?

No in the shell, you can use it in the server with node child_process.exec(‘netstat | grep https’) and getting the output from a promise

1 Like