Ubuntu 16.04 local structures MQTT Mosquitto

Mosquitto realized MQTT v3.1 is a protocol of open source message broker software, including server-side and client-side, cross-platform deployment, provide lightweight support publish / subscribe messaging push mode, the device equipment short message communications between ease of use. The following is in Ubuntu16.04 environment, local MQTT build server and client:

First, install mosquitto

1.1 introduced mosquitto warehouse and updates

sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa

sudo apt-get update

1.2 server and client installation mosquitto

sudo apt-get install mosquitto

sudo apt-get install mosquitto-clients

1.3 start / stop service mosquitto

sudo service mosquitto start

sudo service mosquitto stop

1.4 View service status mosquitto

sudo service mosquitto status (on behalf of a running start)

Second, the test

2.1 Open a terminal, subscribe to topics

mosquitto_sub -h localhost -t "mqtt" -v

[-H] Specifies the server to connect to MQTT 
[-t] subscribe to a topic, here mqtt 
[-v] prints more debugging information

2.2 Open another terminal, post a topic

mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"

[-H] Specifies the server to connect to MQTT 
[-t] push messages to the designated topic 
[-m] specifies the message content

2.3 and use wireshark capture tool for MQTT protocol field in-depth analysis, the following is the command-line installation under Ubuntu 16.04 wireshark steps:

https://www.linuxidc.com/Linux/2016-08/134526.htm

 

Guess you like

Origin blog.csdn.net/weixin_42411153/article/details/95310684