Search code examples
mqttmosquitto

How do I subscribe to all topics of a MQTT broker


I want to connect a client which will monitor all the topics of the broker to respond to the events when I don't know what are names of topic.


Solution

  • Subscribing to # gives you a subscription to everything except for topics that start with a $ (these are normally control topics anyway).

    It is better to know what you are subscribing to first though, of course, and note that some broker configurations may disallow subscribing to # explicitly.