ubuntu mosquitto

环境

Ubuntu21

安装

sudo apt-get install mosquitto

## 客户端
sudo apt-get install mosquitto-clients

启动服务

mosquitto -c /etc/mosquitto/mosquitto.conf -d

发布订阅

参数讲解

参数 意义
-h 服务器主机,默认localhost
-t 指定主题
-u 用户名
-P 密码
-i 客户端id,唯一
-m 发布的消息内容
## 订阅
mosquitto_sub -h localhost -t "test" -i "client1"

## 发布
mosquitto_pub -h localhost -t "test" -i "client2" -m "Hello World!"
posted @ 2022-04-04 20:55  奔跑的兔  阅读(117)  评论(0编辑  收藏  举报