文章目录
创建本地 broker
https://test.mosquitto.org/
托管一个公开可用的 Mosquitto MQTT server/broker
mosquitto --help
mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300)
mosquitto is an MQTT v3.1.1/v3.1 broker.
Usage: mosquitto [-c config_file] [-d] [-h] [-p port]
-c : specify the broker config file.
-d : put the broker into the background after starting.
-h : display this help.
-p : start the broker listening on the specified port.
Not recommended in conjunction with the -c option.
-v : verbose mode - enable all logging types. This overrides
any logging options given in the config file.
See http://mosquitto.org/ for more information.
开源 mqtt project
paho: https://www.eclipse.org/paho/
https://www.eclipse.org/paho/downloads.php
https://www.eclipse.org/paho/clients/python/
mqtt client
使用MQTT.fx接入物联网平台
- MQTT.fx 是一款基于 Eclipse Paho,使用 Java 语言编写的 MQTT 客户端工具,支持通过 Topic 订阅和发布消息。
使用MQTT.fx接入物联网平台
https://www.alibabacloud.com/help/zh/doc-detail/86706.htm
http://mqttfx.jensd.de/index.php
Paho-MQTT C接入示例
https://www.alibabacloud.com/help/zh/doc-detail/146611.htm
mosquitto client
安装 mosquitto client
# 安装 mosquitto client
sudo snap install mosquitto # version 1.6.9, or
sudo apt install mosquitto-clients
订阅信息
# 订阅信息
mosquitto_sub -h test.mosquitto.org -t "#" -v
mosquitto 的用法
mosquitto — an MQTT broker
https://mosquitto.org/man/mosquitto-8.html
开启 mqtt broker
mali@ubuntu:~$ mosquitto -p 6000
1594970141: mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) starting
1594970141: Using default config.
1594970141: Opening ipv4 listen socket on port 6000.
1594970141: Opening ipv6 listen socket on port 6000.
1594970189: New connection from 127.0.0.1 on port 6000.
1594970189: New client connected from 127.0.0.1 as mosqsub|22878-ubuntu (c1, k60).
1594970321: New connection from 127.0.0.1 on port 6000.
1594970321: New client connected from 127.0.0.1 as mosqpub|22920-ubuntu (c1, k60).
1594970321: Client mosqpub|22920-ubuntu disconnected.
mali@ubuntu:~$ mosquitto_sub -p 6000 -t "#"
this is my first attempt
mali@ubuntu:~$ mosquitto_pub -p 6000 -t "topic/test" -m "this is my first attempt"
mqtt test
mosquitto 连接aliyun
mosquitto_sub -h a1DXwtzsiP1.iot-as-mqtt.cn-shanghai.aliyuncs.com -p 1883 -u '1905141934&a1DXwtzsiP1' -P 2AA01043034E5D330FC0180FF0F795C8C3183836 -i 'F0FE6BAA8B46|securemode=3,signmethod=hmacsha1,timestamp=1592747707145|' -t "#"