Article Directory
1. Download and install
1.1. Download address
https://mosquitto.org/download/
version: mosquitto-1.6.9
1.2. Installation
1.2.1. Binary installation
Quick installation (higher versions support snap mode, a quick way to solve dependency package problems)
snap install mosquitto
1.2.2. Windows version binary installation
1.2.2.1. Download and installation
mosquitto-1.6.8-install-windows-x64.exe (~1.4 MB) (64-bit build, Windows Vista and up, built with Visual Studio Community 2017)
1.2.2.2. Configure environment variables
1.2.2.3. Start the server
Switch to the installation directory D:\Program Files\mosquitto, and run
mosquitto -c mosquitto.conf
1.2.2.4. Subscription
mosquitto_sub -v -t {topic}
1.2.2.5. Release
mosquitto_pub -t {topic} -m {message}
1.2.3.Ubuntu compile and install
Dependent library installation
Install ssl dependency package
$ sudo apt-get install libssl-dev
mosquitto-1.6.9.tar.gz (319kB) (GPG signature)
Unzip
$ tar zxvf mosquitto-1.6.9.tar.gz
$ cd mosquitto -1.6.9
$ make
$ sudo make install
Start the service
$ mosquitto -v
2. Basic use of Ubuntu command line (QoS0)
2.1. Start the server
$mosquitto -v
2.2. A client A subscribes
mosquitto_sub -v -t aloha
2.3. A client B release
mosquitto_pub -t aloha -m hello After
client B connects to the server, it publishes a topic message and disconnects; the
server forwards it to client A;