3 Tools to Simulate an MQTT Client
When it comes to handling MQTT messages, here are a few tools that will help you simulate clients to mimic pub-sub messaging transport.
Join the DZone community and get the full member experience.
Join For FreeMQTT 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.
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 because 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. 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.
Nowadays, there are many tools that let you simulate 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.
1. MQTTLens
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 that's simple and easy to grasp, making it one of the most common in the world.
MQTTLens allows connections to more than one broker at the same time, supporting all the available connections option from the MQTT spec, though not persistent sessions. A cool feature is the display of JSON payloads. They're presented in a nice way and can easily be understood.
MQTTLens is particularly well-suited for people who need basic pub/sub functionality without having power needs.
To get a better an idea how its works, you can reference to this video tutorial:
2. MQTT.fx (Available for Win/MacOSX/Linux)
MQTT.fx (or here) is an 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 a quick and easy-to-use desktop tool for MQTT debugging and testing.
This tool supports importing/exporting Topics and Clipboard messages. Furthermore, the 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.
3. MQTT-Spy (Based on Java 8)
MQTT-Spy (GitHub) has a very nice way to display basic MQTT publish/subscribe mechanisms. Having different tabs for connections to several brokers, it makes it easy to publish and subscribe at the same time!
The areas of the pub/sub window are: publish, new subscription, subscription, and messages. These can be closed to make room for currently operational windows. MQTT-Spy also comes with advanced features like scripting, filtering, searching, decoding and 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 simple access. It is easy to open the file in any text editor and make a 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 these 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.
Published at DZone with permission of Maria Hernandez, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments