Using MQTT.fx to connect to EMQX Cloud

This article will take MQTT.fx as MQTT client test tool to connect to MQTT Cloud Service - EMQX Cloud. Through this article, you will be able to quickly understand the basic usage of MQTT.fx and the basic concepts and usage of the MQTT protocol.

Introduction to MQTT.fx

MQTT.fx is the most popular MQTT desktop client tool currently. The major version of MQTT.fx 1.0 is developed by Jens Deters using JavaFX technology, which is a Java virtual machine application. Unfortunately, the maintenance of MQTT.fx has now stopped maintenance and Softblade company has sponsored the development and released its commercial version MQTT.fx® 5.0, which is operated with a fee-based license. MQTT.fx in this article refers to version 1.0 without special instructions.

It contains mainstream MQTT client functions:

In addition, MQTT.fx also has other excellent features:

  • The software is free, and its open source protocol is Apache 2.0 license
  • Support cross-platform
  • Support $SYS topic subscription management MQTT Broker
  • Complete log console
  • Support JavaScript to process messages
  • Support predefined templates

But there are also defects:

  • MQTT 5.0 protocol is not supported
  • Only one connection can be established at a time, which is inconvenient for multi-connection debugging
  • WebSocket protocol is not supported and the situation of MQTT over Webscoket cannot be debugged

Introduction to EMQX Cloud

EMQX Cloud is a fully managed cloud-native MQTT service launched by EMQ company that can connect to a large number of IoT devices and integrate various databases and business systems. As the world's first fully managed MQTT 5.0 public cloud service, EMQX Cloud provides MQTT message service with one-stop operation and maintenance management and a unique isolation environment.

In the era of the Internet of Everything, EMQX Cloud can help users quickly build industry applications for the IoT area and easily realize the collection, transmission, calculation, and persistence of IoT data.

This article will use Free Public MQTT Server provided by EMQX Cloud as the MQTT server address for this test. The server access information is as follows:

  • Broker:
  • TCP Port: 1883
  • SSL/TLS Port: 8883

For more details, please visit EMQX Cloud website or check EMQX Cloud documentation.

MQTT.fx usage


The main page is shown in the figure below. The top part is the MQTT Broker connection address bar and its connection configuration. The following function Tabs include Publish column, Subscribe column, Scripts column, Broker Status column, Log column for log information control.

MQTT.fx Preview

Each tab supports dragging into a separate window, as shown in the following figure:

MQTT.fx separate window


First, the MQTT client and Broker need to establish a connection to communicate. Click the configuration icon on the right side of the input box in the connection address bar to enter the specific connection configuration.

MQTT.fx Connect

Select the Profile Type as MQTT Broker. Fill in for Broker Address and 1883 for Broker Port, as shown in the figure below:

MQTT.fx Connect Setting

Click OK to confirm the configuration, return to the main interface, and click Connect. It can be seen that the circle on the right turns to green, indicating that the current connection is successful, as shown in the following figure:

MQTT.fx Connect Successful

Subscribe/Publish messages

Once the connection is established, you can start subscribing to messages. Because the MQTT protocol adopts the subscribe/publish method, we need to subscribe to the topic after connecting. After a message is generated on the topic, we can receive the messages from EMQX cloud.

EMQX Platform

Click to enter the Subscribe Tab to enter /testTopic/1 in the topic box. Then, click the Subscribe button, and the list of subscribed topics will appear on the left. The current number of subscribed topics is 0, as shown in the following figure:

MQTT.fx Subscribe

After that, we will publish the message to the broker. Return to Publish, enter the topic /testTopic/1, and enter the message of "hello world" in the message input box, as shown in the following figure:

MQTT.fx Publish

Click Publish to send the messages and return to the Subscribe Tab. We can find that the subscribed topic /testTopic/1 has received the message, as shown in the following figure:

MQTT.fx Receive Messages

We use the client MQTT.fx to send the message "hello world" to the topic /testTopic/1 under EMQX Cloud. All clients that have subscribed to this topic will receive this message, including the sending clients who have just subscribed to this topic.


You can customize the message publish logic more flexibly by using the script. Click Script Tab and Edit to modify the script content as follows:

function execute(action) {
    mqttManager.publish("/testTopic/1", "hello world from script");
    return action;

Among them, mqttManager is the API to open the MQTT.fx script function, mainly including the following:

  • publish(),publish messages
  • subscribe(),subscribe to topics
  • unsubscribe(),unsubscribe to topics
  • output,output messages to the console

Click Execute, return to Subscribe column and find that the message is added with the content of "hello world from script". The script sending function is normal, as shown in the figure below:

MQTT.fx Script


In the log, we can view the interaction process between MQTT.fx and EMQX Cloud, such as topic subscription, message publish, message reception, etc.:

MQTT.fx Logs

SSL/TLS connection

We take CA self-signed service as an example to show how to enable SSL protocol to connect to EMQX Cloud.

Open the settings, fill in the Broker Address and Broker Port ( and 8883 respectively) like normal connections, select the SSL/TLS item, select the TLSv1.2 protocol, check CA signed server certificate , and then select the application, as shown in the figure below:


Click Connect, and you can see that the lock icon on the right is closed, indicating that SSL is enabled. Check the log, and you will find the words related to SSL connection port 8883. The connection to SSL/TLS is successful.

MQTT.fx Connect Logs

MQTT.fx SSL/TLS Status

Try EMQX Cloud for Free
No credit card required
Get Started →

Related Posts

The comparison of usual MQTT client tools in 2020

MQTT client tools are used to connect to the MQTT broker to subscribe and publish. This article evaluates the usual MQTT client tool for reference.

Using MQTTLens to connect to EMQX Cloud

This article will give you a quick overview of the basic usage of the MQTTLens, as well as the basic concepts and usage of the MQTT protocol.

Shifan Yu 2021-08-27
Using MQTT Explorer to connect to EMQX Cloud

This article will give you a quick overview of the basic usage of the MQTT Explorer, as well as the basic concepts and usage of the MQTT protocol.

Xun Ouyang 2021-08-17