hivemq / mqtt-cli

MQTT CLI is a useful command line interface for connecting various MQTT clients supporting MQTT 5.0 and 3.1.1
https://hivemq.github.io/mqtt-cli/
Apache License 2.0
310 stars 47 forks source link

Print topic for incoming messages #325

Closed hurenkam closed 1 year ago

hurenkam commented 1 year ago

Problem or use case

When monitoring multiple topics from the same instance, it is not clear on which topic the message are coming in. Especially when listening to multiple xxx/# topics, this makes it hard to see what exactly is happening.

Preferred solution or suggestions

Would like to see a topic header printed just before the message itself is printed, perhaps enabled through a command line switch.

ghost commented 1 year ago

Hi @hurenkam, thanks for your request. Did you try to use the subscribe option -T or --showTopics?

For example:

mqtt sub -h broker.hivemq.com -t cli-show-topic/# -T

will result in:

cli-show-topic/test1: message1

if a publish is sent like this:

mqtt pub -h broker.hivemq.com -t cli-show-topic/test1 -m message1

The same functionality is also available inside the shell mode. Does this resolve your issue?