How to know subscribed users and their topics?

Hi everyone

I have been looking for a way to know which clients are connected my broker and to which topics. I'm using esp32 as clients with PubSubClient.h library. the esp32 has to five a client name on the connection moment, and later it has to subscribe to some topic if we expect it to receive their we should be able to see this information..correct?

I'm currently using mosquitto and if I subscribe to $SYS/broker/clients/connected, $SYS/broker/clients/total or $SYS/broker/subscriptions/count I get a payload with the current number of clients connected , total clients or subscriptions made. But never the name of the clients or the topics.

Is there a way?

Thank you.
Cheers, LuĂ­s Pereira.

There is nothing in the MQTT protocol that defines what Brokers should do in this area. Any solution (if there is one) will be specific to the particular broker you are using - something you don't mention.

I'm guessing you're using mosquitto? I do not think it exposes the sorts of details you are looking for on any of the $SYS topics.

Thank you for the response. Yes I'm using mosquitto, and accoding to this thereisn't a $SYS for specific topics. But what about other brokers, do you know anything that comes close to what I mention?
Thank you.
Cheers, LuĂ­s Pereira.

The built in dashboard of emqx allows you to see who is subscribing what topics

1 Like

It is likely that Mosquitto will show that data in its logs if you turn up the logging level, you would need to access it from there.

Some other thoughts here: Get a list of connected client IDs from MQTT client - Stack Overflow

Not sure if MQTT v5 adds anything in this area?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.