Ubuntu MQTT mosquitto
https://github.com/eclipse/paho.mqtt.c.git
https://github.com/eclipse/paho.mqtt.cpp.git
Paho MQTT C Client Library: MQTT Client library for C (MQTTClient)
GitHub - eclipse/mosquitto: Eclipse Mosquitto - An open source MQTT broker?
1. install:
https://mosquitto.org/download/
2. conf:
打开/etc/mosquitto/mosquitto.conf,发现需要将配置文件放置于/etc/mosquitto/conf.d/目录下,示例文件可以从/usr/share/doc/mosquitto/examples/目录下提取,发现其是一个压缩包,将其解压缩,然后复制到/etc/mosquitto/conf.d/目录下。
xx@ubuntu:/etc/mosquitto$ cd? /usr/share/doc/mosquitto/examples/
xx@ubuntu:/usr/share/doc/mosquitto/examples$ ls -lh
总用量 24K
-rw-r--r-- 1 root root 230 Apr? 3? 2021 aclfile.example
-rw-r--r-- 1 root root 12K Apr? 3? 2021 mosquitto.conf.gz
-rw-r--r-- 1 root root? 23 Apr? 3? 2021 pskfile.example
-rw-r--r-- 1 root root 355 Apr? 3? 2021 pwfile.example
cd? /usr/share/doc/mosquitto/examples/
sudo gzip -d mosquitto.conf.gz
sudo cp mosquitto.conf /etc/mosquitto/conf.d/
手动启动mosquitto,方便查看日志排查出现的问题。
mosquitto -c /etc/mosquitto/conf.d/mosquitto.conf -v
配置成无用户密码校验和无TLS连接
listener 1883
allow_anonymous true
配置文件如上配置,然后启动mosquito。
3. stat:
service mosquitto status??? // 查看服务状态
service mosquitto start???? // 启动
service mosquitto stop????? // 停止
service mosquitto restart?? // 重启
4. test:
mosquitto_sub -h "192.168.10.111" -p 1883 -t "mqtt/test" -v
mosquitto_pub -h "192.168.10.111" -p 1883? -t "mqtt/test" -m "hello"
Reference:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!