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.
4 Answers
103
votes
66
votes
9
votes
Concrete example
mosquitto.org is very active (at the time of this posting). This is a nice smoke test for a MQTT subscriber linux device:
mosquitto_sub -h test.mosquitto.org -t "#" -v
The "#" is a wildcard for topics and returns all messages (topics): the server had a lot of traffic, so it returned a 'firehose' of messages.
If your MQTT device publishes a topic of irisys/V4D-19230005/
to the test MQTT broker , then you could filter the messages:
mosquitto_sub -h test.mosquitto.org -t "irisys/V4D-19230005/#" -v
Options:
- -h the hostname (default MQTT port = 1883)
- -t precedes the topic