MQTT is based on a publish/subscribe model for message communication. The client can be both a publisher (publish a message) and a subscriber (subscribe to a topic). That is, when a client publishes a message to the broker, the broker will forward the message to clients subscribed to this topic after receiving it.
This chapter will introduce the commonly used MQTT client tools, and will walk you through the process of establishing client connections, subscribing to topics, publishing messages, as well as receiving and viewing messages.
Below is the typical workflow on how a message is published and then received by the subscriber.
- Publishers and subscribers initiate the connection request to EMQX with the correct connection URL and authentication information. Note: Both are connected to the same EMQX;
- The subscriber subscribes to the topic. By default, messages with no matching subscribers will be discarded immediately;
- The publisher publishes messages, please ensure that the topic of the message can be matched with the subscriber, and the subscriber has subscribed to the corresponding topic;
- The subscriber receives the message.
In the next section, we will introduce how to test the connection with different client tools, including Dashboard Websocket and MQTT X.