How can I see the messages that are published to the Mosquitto broker which has been locally installed in Ubuntu?

I have used Spring Integration and think it worked fine. I also tried commands in the Command Prompt after searching on the Internet to view the published data in broker.

  • There is an excellent blog post on this, entitled Dissecting MQTT using Wireshark. If you Google, there is more, but I think that blog post should be sufficient.
    – Mawg
    Sep 13, 2018 at 8:24
  • @sam You mention that you tried some commands in the Command Prompt—do you remember what you used, or can you find the resource you read? It's difficult to know exactly what to suggest without knowing the exact commands you tried.
    – Aurora0001
    Sep 13, 2018 at 9:28
  • 1
    Do not cross post the same question to multiple Stack Exchange sites stackoverflow.com/questions/52309414/…
    – hardillb
    Sep 13, 2018 at 10:39

1 Answer 1


To publish a message you should try like this:

mosquitto_pub -h localhost -t YourTopic -m "Your message"

Now if you want to see that message you should try like this:

mosquitto_sub -h localhost -t YourTopic

Please note in some circumstances you cannot see a published message:

  1. Your broker is not installed properly
  2. Your broker is installed on a device, and also your subscriber and publisher devices are different devices. In that case you should make sure all the devices are connected to the same network and all of them can listen each other without firewall interfering (try pinging all devices from each other).
  • Can u explain how the MQTT broker interacts with the clients after publishing messages, it would be appreciable if you give a program based example.
    – sam
    Sep 14, 2018 at 8:46
  • Actually MQTT is a lightweight machine to machine communication protocol that works with pub/sub on a topic . It means that it runs on a server(broker), devices can now connect to broker and publish/subscribe to topics . when a device subscribes to a topic , can listen everything that is publishing on that topic . more informations can be explained as a different question. Sep 14, 2018 at 9:59
  • Thank u for your reply. It worked , But now I replaced musquitto with EMQ broker.My question is whether the query is same for both the brokers or not,if not give the query. Is there any difference between them.
    – sam
    Sep 18, 2018 at 12:28
  • EMQ commands are the same as mosquitto with little differences , you can see the full command documantation on EMQ Broker site > Documantation > Commands. Sep 18, 2018 at 12:35

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.