MQTT is an “Internet of Things” connectivity protocol. Designed as an extremely lightweight publish/subscribe messaging transport, It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium (Source: MQTT.org).
MQTT is especially useful to push data to your devices. Imagine a cloud-controlled device to open/close a door remotely. In the case of HTTP, the device would have to continuously make GET requests to the server to see if there’s a change in a variable, say “Door Control Variable”, and then make an action depending on the last reading. This takes a lot of requests and is inefficient since it depends on the polling frequency. With MQTT, the device can “listen” to the cloud and only be notified when there’s a change in the variable. This way, the connection between the device and the cloud is left open but data travels only when necessary, saving battery, network bandwidth, and improving the real-time capabilities.
The Top Three
In this protocol the central communication point is the MQTT broker, it is in charge of managing all messages between the senders and the receivers; as would be the MQTT broker of Ubidots. To interact with an MQTT broker you’ll need an MQTT client, which is the one in charge of publishing/subscribing messages to the broker. The MQTT client includes a topic into the message, it is in charge of routing the information to the MQTT broker.
Now a day there are many tools that let you simulate a MQTT clients without using any hardware, you need only establish the communication between the MQTT broker and the MQTT client! Below you will find Ubidots top 3 tools for simulating MQTT requests.
This tool can be installed via the Google Chrome Web Store with just one click, making it easy and convenient to get started. MQTTLens connects to an MQTT broker and is able to publish and subscribe to MQTT topics using an interface simple and easy to grasp, making it one of the most common used in this world.
MQTTLens allow connections to more than one broker at the same time, supporting all the available connections options from the MQTT spec, but not persistent sessions. A cool feature is the display of JSON payloads which is presented in a nice way and can easily be understand.
MQTTLens is particularly well suited for people who need basic pub/sub functionality without having power needs.
To get a better a idea how its works, you can reference to this video tutorial.
2. MQTT.fx (available for Win/MacOSX/Linux, Link)
MQTT.fx is a MQTT Client written in Java and based on Eclipse Paho. Due to the native packaging available for JavaFX, there are binaries for Windows, MacOSX and Linux, which makes the installation a breeze, MQTT.fx aims to be an quick and easy to use desktop tool for MQTT debugging and testing.
This tool supports import/export of Topics and Clipboard messages. Furthermore standard publish/subscribe functionality provides support for $SYS topics and connection profiles for connecting to different brokers. The connection profiles allow the configuration of connection options like client id, SSL/TLS, username/password and Last Will and Testament. Also, MQTT.fx lets you view publisher and subscriber at the same time by detaching one of the tabs.
MQTT-Spy has a very nice way to display basic MQTT publish/subscribe mechanisms. Having different tabs for connections to several brokers, it make it easy to publish and subscribe at the same time!
The areas of the pub/sub window are publish, new subscription, subscription & messages, These can be closed to make room for currently operational windows. MQTT-Spy also come with advanced features like scripting, filtering, searching, decoding & formatting on received messages, and graphing/charts.
Another handy feature is that it logs every published and received message in the standard output into a file for simply access. It is easy to open the file in any text editor and make deeper analysis of the messages, which is often necessary when dealing with many MQTT messages.
Tools to simulate an MQTT client
Now that you have the tools needed it to simulate an MQTT client, you can test with the Ubidots' MQTT broker. Please reference the MQTT API reference for additional information on subscribing and publishing requests.
There are a number of tools to publish or subscribe on MQTT topics, which make this easier, but this top 3 will help you start working with MQTT! Reference to the official MQTT website where you can find a list of these tools and more exploration.
This article was originally published in Ubidots' Blog on July 11, 2017.