Webinar
Unifying Data from Vehicle to Cloud | Register Now →

MQTTX CLI Adds Support for Automatic Reconnection and The Ability to Save and Read Local Files

MQTTX Team
Dec 14, 2022
MQTTX CLI Adds Support for Automatic Reconnection and The Ability to Save and Read Local Files

In early November, the MQTTX team released version 1.9.0. This update includes support for MQTT performance testing via MQTTX CLI and a help page to help users learn more about MQTT within the desktop application. Additionally, the update includes various improvements and bug fixes.

The team currently focuses on version 1.91. In this version, the MQTTX CLI will be able to automatically reconnect, save and read local configuration files, and convert messages to different formats. The desktop application will support the setting of the scroll interval and will fix some issues.

Download the latest version here: https://www.emqx.com/en/try?product=MQTTX

Desktop client

Support setting scroll interval

In v1.9.1, we add a configuration item: Auto scroll interval. This option is used to set the interval of scrolling of the message list and can only be configured when “Auto scroll” is enabled.

In previous versions, the "Auto scroll" feature automatically scrolled the list of messages down as new messages came in. However, this made it difficult for users to see the content of messages if the scrolling speed was too fast. To address this issue, we have added a setting on the Settings page that allows users to specify the interval for scrolling in seconds. This allows users to adjust the scrolling speed to their preference and ensures that the messages are automatically scrolled to the bottom of the list at a pace that is comfortable for them to read.

MQTTX support setting scroll interval

Adjust the help page

There was a help page for users to learn about the MQTT in previous versions. In v1.9.1, we add a new menu called "Everything about MQTT" to the Help section. This menu provides users with a range of information about MQTT, including its basic concepts, configuration parameters, topics and messages, QoS, and client-side programming. This makes it easy for users to learn more about MQTT and its features.

Everything about MQTT

Other updates

  • Support the configuration of user properties to add duplicate keys with different values. It is fully compatible with the MQTT protocol.
  • Optimize UI design and interaction.
  • Fix some known bugs.

MQTTX CLI

Support automatic reconnection

In previous versions, MQTTX CLI would automatically disconnect and exit if the MQTT server encountered an exception. Users have to reconnect to the server manually when it is recovered. In v1.9.1, we provide a mechanism for automatic reconnecting so that MQTTX CLI automatically reconnects after disconnecting from the MQTT server.

MQTT CLI

The number of reconnection attempts is limited, and once this maximum is reached, MQTTX CLI will exit to prevent further attempts. The number of attempts is set to 10 by default, but this can be adjusted using the -maximun-reconnect-times option.

# For example, change the number of attempts to 5

mqttx conn -h 'broker.emqx.io' -p 1883 --maximun-reconnect-times 5

In addition to the number of attempts, we also add a configuration setting for the reconnect interval. If the MQTT server experiences an exception, MQTTX CLI will attempt to reconnect according to the reconnection interval measured in milliseconds. The interval is set to 1000 milliseconds by default, but this can be customized using the -reconnect-period option.

Note: If the reconnect interval is set to 0, auto-reconnect will be disabled.

# For example, change the reconnection interval to 5000 milliseconds

mqttx conn -h 'broker.emqx.io' -p 1883 --reconnect-period 5000

The bench command also offers automatic reconnection support and allows for the automatic reconnection of any connections that are disconnected abnormally.

MQTT Bench

Support saving and reading local configuration files

In earlier versions, users had to manually input connection parameters each time they wanted to connect to an MQTT server, which was inconvenient. In v1.9.1, we added the ability to read and store local configuration files. This allows users to save their connection parameters to a file and then easily read the parameters from the file when they want to connect. The feature also supports saving all CLI commands to the configuration file.

To save a configuration file, input the --save parameter and the file path when running a command. By default, the file will be named mqttx-cli-config.json and saved in the directory where the current command is being run.

To read a configuration file, use the --config parameter and the path to the configuration file when running a command.

Note: The MQTTX CLI supports both JSON and YAML, but when using the -save parameter, you need to specify the file format, such as -save mqttx-cli-config.json or -save mqttx-cli-config.yaml.

Support saving and reading local configuration files

Support specifying message format

In previous versions, MQTTX CLI only supported String messages. If users sent messages with hex type, there were problems converting them to string. Therefore, in v1.91, MQTTX CLI add a feature for converting the message format so that users can specify the format of incoming messages.

The following formats are supported:

  • String
  • Hex
  • Base64
  • JSON

In addition to the String format, you can specify the message format by simply adding the -format parameter when running the sub command, such as -format hex.

Support specifying message format

MQTTX Web

MQTTX Web makes some changes to the functions and page layouts in accordance with the MQTTX desktop application.

You can have a quick experience here: https://mqttx.app/web-client/

Future plans

MQTTX is continuing to be improved to provide users with more practical and powerful features and facilitate the development and testing of IoT-based applications and services. Next, we will focus on the following aspects:

  • Optimize the performance for receiving and storing messages to ensure that the system runs smoothly when there are too many messages coming in.
  • Support MQTT Debug.
  • Support Sparkplug B format.
  • Chart automatically based on incoming messages.
  • Add Plugins.
  • Support automated test script (Flow).
Try MQTTX for Free
Get Started →

Related Posts

Feb 11, 2020MQTTX Team
MQTTX Guideline

MQTT X is suitable for users who are building their own MQTT message server to test connections, subscribing and publishing messages, etc. When using a client, the user can be either a publisher or a subscriber.

Aug 11, 2022MQTTX Team
MQTTX CLI: A Powerful and Easy-to-Use MQTT CLI

In order to provide more choices and convenience for users to implement MQTT connection tests, MQTT X v1.8.0 adds the command line as a form of interaction - the MQTT X CLI.