In this paper, MQTTBox will be used as an MQTT client test tool to access the MQTT Cloud service - EMQ X Cloud. In this article, you will quickly understand the basic usage of MQTTBox and the basic concepts and use of the MQTT protocol.
MQTTBox is a personal MQTT client tool developed by Sathya Vikram. It was originally used as an extended installation on Chrome, and later rewritten as an open source desktop cross-platform software. The interface is simple and direct, and supports multiple clients to be online at the same time. However, it is still inconvenient to switch between clients and send messages to each other. MQTTBox is a worthwhile MQTT client tool with powerful cross-platform features in Chrome combined with simple load testing capabilities.
MQTTBox fully supports the following functions:
- By supporting Chrome OS, Linux, macOS, Windows Chrome storage is easy to install, support Linux, macOS, Windows independent installation
- Supports MQTT, MQTT over WebSocket, and multiple TCP encryption connections
- Saves a history of sent messages
- Copy/paste messages from history
- Save the subscription message history
- Simple performance tests that test the Broker's load and visualize the results on a chart
Introduction to EMQ X Cloud
EMQ X Cloud is a fully managed Cloud native MQTT service launched by EMQ company that can connect massive Internet of Things devices and integrate various databases and business systems. As the world's first fully hosted MQTT 5.0 public Cloud service, EMQ X Cloud provides a one-stop operation and maintenance escrow, unique isolated environment MQTT messaging service.
In the era of the Internet of Everything, EMQ X Cloud can help users quickly build industrial applications oriented to the Internet of Things, and easily realize the collection, transmission, calculation and persistence of Internet of Things data.
In this paper, the free public MQTT server provided by EMQ X Cloud will be used as the ADDRESS of the MQTT server for this test. The server access information is as follows:
- Broker: broker-cn.emqx.io
- TCP Port: 1883
- SSL/TLS Port: 8883
For more details, visit the EMQ X Cloud website or view the EMQ X Cloud documentation.
After opening the software, enter the main interface of the software and click Create MQTT Clinet button in the top menu bar to enter the Create MQTT client page.
Create a connection
After entering the page of creating MQTT client, fill in Host, select connection protocol and other MQTT related configuration information, click the Save button at the bottom to immediately create a connection client.
Note: When filling in Host, you need to fill in the complete address, including the port number of the connection. If the connection is WebSocket, add Path. If MQTT Broker enables Username/Password authentication, enter Username/Password on the configuration page
If the button in the upper right corner shows Connected and is green, it means that the MQTT client has been successfully Connected. Click it again to disconnect the client.
Subscribe to the topic
Once the connection is established, you can start subscribing to messages. Since the MQTT protocol uses a publish/subscribe model, we need to subscribe to a topic after the connection and then receive a push from the EMQ X Cloud when a message is generated on the topic.
There are two send and subscribe input boxes by default in MQTTBox's customer view page. If you have multiple subscriptions or different publishing content, you can Add more. Click the Add Publisher and Add Subscriber buttons on the top menu bar to Add and manage multiple publishing subscriptions.
We first input Topic: testTopic/MQTTbox in the yellow box on the right, select QoS level, click Subscribe button to Subscribe related Topic.
MQTT message published
Then enter the Topic to be published in the blue box, enter the testTopic/mqTTbox that you subscribed to just now, select the QoS level, select the default Payload Type, and support String/JSON/XML/Characters. Enter a piece of JSON in the Payload box and click Publish.
At this point, we can see that in the subscription box on the right, the message just published appears. At this point, we have created an MQTT client and successfully tested the ability to connect, publish, subscribe, and more.
The TLS/SSL connection
MQTTBox also supports TLS/SSL connections in addition to regular connections.
If you are using the EMQ X Cloud, you can refer to this document to create the certificate. We can go to the client view page, select the protocol MQTTS/TLS or WSS, and choose Save.
For bidirectional authentication, you can select the CA certificate file, client certificate, and client Key file on the configuration page, and then select Connection. Before connecting, determine the TLS/SSL connection port and modify it.
Original link: www.emqx.com/zh/blog/con...