1

I got the Dynamic Security of mosquitto mostly working. However, I'm not sure how to use the listClients command through the json approach, as explained here:

https://github.com/eclipse/mosquitto/blob/master/plugins/dynamic-security/README.md#list-clients

For example, this command works perfectly for me and it lists all the users stored in my /var/lib/mosquitto/dynamic-security.json file:

mosquitto_ctrl -u steve -P Pass1234 dynsec listClients

However, when I use the JSON approach like this:

mosquitto_pub -u steve -P Pass1234 -t '$CONTROL/dynamic-security/v1' -m '{"commands":[{"command": "listClients","verbose":false,"count": -1,"offset": 0}]}';

The result is no output at all.

How do I get the list of clients through the JSON approach as indicated in the README.md file above?

1
  • Just to be sure, you are running an equivalent mosquitto_sub command to see the response? mosquitto_pub will never return anything.
    – hardillb
    Feb 21, 2022 at 9:17

1 Answer 1

1

Assume the answer to the question in the comments is "no"

You need to also run:

mosquitto_sub -u steve -P Pass1234 -v -t '$CONTROL/#'

To subscribe to the correct response topic.

The mosquitto_pub command will only ever publish messages, it will subscribe to any topics and print out messages.

3
  • That worked! Can you explain why the subscribed topic is $CONTROL/#? I would have guessed it to be $CONTROL/dynamic-security/v1 so that it is same as the topic that I published to. Feb 21, 2022 at 16:16
  • # is a wildcard meaning any number of topic levels, so $CONTROL/# matches all topics that start with $CONTROL/. I wasn't 100% sure what topic the response would be on which is why I used the wildcard and the -v option which causes mosquitto_pub to print the topic before the message.
    – hardillb
    Feb 21, 2022 at 16:25
  • Ooooh!!!! the -v option discloses this topic $CONTROL/dynamic-security/v1/response. So then I mosquitto_sub -u steve -P Pass1234 -t $CONTROL/dynamic-security/v1/response, which also worked! So I'll use the $CONTROL/dynamic-security/v1/response to ignore anything not related to dynamic security Feb 21, 2022 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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