Network Environment

  When the mqtt protocol is on the public network, the public network server cannot actively send requests to the LAN device. The configuration can only be accessed/used normally under the LAN.

Device Configuration

Server Configuration

Set MQTT related parameters, as shown in the figure below Can set ID, user name, password After the ID is confirmed, the main topic, device operation interface and event publishing interface are determined.

Here is the protocol port, so use 1883

The default TCP ports occupied by the EMQ 2.0 message server include:

1883 MQTT Protocol Port

8883 MQTT/SSL Port

8083 MQTT/WebSocket Port

8080 HTTP API Port

18083 Dashboard Management console port

After saving the configuration, refresh the page to check whether the server connection status is successful.

emqx Download Installation Guide (Server)

1. Download the zip package of the EMQ X version to be installed through https://www.emqx.com/en/downloads/broker or https://github.com/emqx/emqx/releases.

在这里插入图片描述

在这里插入图片描述

2. Unzip the package

3. Start EMQX Broker Enter the directory where emqx is unzipped, enter the bin directory, and execute the command script under it

$ emqx start

$ emqx_ctl status
Node 'emqx@127.0.0.1' 4.3.5 is started

4.Stop EMQ X Broker

$ emqx stop
ok

MQTT Box Download Installation Guide (Client)

1. Download and install Official website download address:

http://workswithweb.com/mqttbox.html

After the download is complete, double-click to open and use:

2. Publish and subscribe messages

(1) MQTT (Message Queuing Telemetry Transport) is a "lightweight" communication protocol based on the publish/subscribe model. It is built on the TCP/IP protocol and was released by IBM in 1999.

The biggest advantage of MQTT is that it can provide real-time and reliable message services for remote devices with very little code and limited bandwidth. As a low-overhead, low-bandwidth instant messaging protocol, it is widely used in the Internet of Things, small devices, mobile applications, etc.

(2) MQTT server The MQTT server is also called a "message broker" (Broker), which can be an application or a device. It is located between message publishers and subscribers, and can:

Receive network connections from clients / Receive application information published by clients / Process subscription and unsubscription requests from clients / Forward application messages to subscribed clients.

(3) MQTT Client An application or device that uses the MQTT protocol and always establishes a network connection to the server. The client can:

Publish information that other clients may subscribe to / subscribe to messages published by other clients / unsubscribe or delete application messages / disconnect from the server.

(4) Publishing and subscribing messages Publishing and subscribing process ClientA connects to Broker; ClientB connects to Broker and subscribes to Topic1; ClientA sends a message to Broker with Topic1 as the topic; Broker receives the message from ClientA, finds that ClientB has subscribed to Topic1, and then forwards the message to ClientB; ClientB receives the message from Broker.

Create a new connection:

The client connects, fill in the information and click Save.

MQTT Client Id:Client ID

Protocol:Select protocol

Host:The IP and port of the server under test

Username And Password:The account and password for connecting to the server. If the server has not set it, you do not need to fill it in;

Client publishes message:

Topic to publish:The name of the topic where the message is published;

Payload:Content of the published message;

The content title of the heartbeat event reply must contain Ack

For details on the heartbeat event response, see the heartbeat event page.

Client subscription message:

Topic to subscribe:The name of the subscription topic;

Payload:Content of the message received after subscription;