I just want to know how many clients are actively connected to my mosquitto server. Or even better, get a list of client ids connected to my mosquitto server. I read some documentation suggesting the topic $SYS/broker/clients/connected will give this information. But this command yielded no response and no results:

mosquitto_sub -h myserver.myserver.myserver -p 9500 -t $SYS/broker/clients/connected -u "my-user" -P "my-password" --capath /etc/ssl/certs/

(I replaced myserver.myserver.myserver and my-user and my-password with actual values.) I verified the connection is working because if I publish a message to the same topic, the message appears.

How can I get a list of clients with active connection to my mosquitto server? Or at least a numeric count of active connections?


Bah I figured it out. I need to put single quotes around the topic so that $SYS isn't interpreted as a variable. So like this:

mosquitto_sub -h myserver.myserver.myserver -p 9500 -t '$SYS/broker/clients/connected' -u "my-user" -P "my-password" --capath /etc/ssl/certs/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.