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.

  • What have you already tried? – hardillb Sep 13 at 6:02
  • used spring integration and think it worked fine.Tried commands in command prompt after searching in internet to view the published data in broker. – sam Sep 13 at 6:21
  • Edit the question to show what you tried and explain why it didn't work and somebody will help you fix it – hardillb Sep 13 at 6:22
  • 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 at 8:24
  • 1
    Do not cross post the same question to multiple Stack Exchange sites stackoverflow.com/questions/52309414/… – hardillb Sep 13 at 10:39
up vote 4 down vote accepted

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 can not 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 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. – Sina Ronaghi Sep 14 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 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. – Sina Ronaghi Sep 18 at 12:35

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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