hlcX's Blog
my note!
Toggle navigation
hlcX's Blog
2.学习
4.群晖
5.CentOS7
6.rasperryPI
linux-mint
关于
归档
标签
偿试在树莓派上安装MQTT
mqtt
2021-03-14 22:06:03
30
0
0
hlcx
mqtt
# 步骤 ``` apt-get update apt-get install mosquitto apt-get install mosquitto mosquitto-clients ``` - 修改 /etc/mosquitto/mosquitto.conf , 在相应位置添加以下内容 ``` log_type error log_type warning log_type notice log_type information connection_messages true log_timestamp true include_dir /etc/mosquitto/conf.d ``` - 启动Mosquitto Server ``` root@raspberrypi:~# /etc/init.d/mosquitto start [ ok ] Starting mosquitto (via systemctl): mosquitto.service. ``` - Testing the Mosquitto server Open up two more terminal windows. In Terminal window 1 type: mosquitto_sub -d -t hello/world n Terminal window 2 type: mosquitto_pub -d -t hello/world -m "Hello from Terminal window 2!" # 最后,可以去看看相关 [判断主人手机是否在家的方法](https://13ua.com:44490/blog/post/hlcx/%E5%88%A4%E6%96%AD%E4%B8%BB%E4%BA%BA%E6%89%8B%E6%9C%BA%E6%98%AF%E5%90%A6%E5%9C%A8%E5%AE%B6%E7%9A%84%E6%96%B9%E6%B3%95) # 自问、自答 ### 自问 > 请教一下,mosquitto的配置文件怎么设置可以改 端口和IP? 我现在是 如下图的IP,造成用访问主机IP地址无法连接服务器. - `netstat -ntulp |grep 1883` ![title](/api/file/getImage?fileId=6367afc83c9b99002b000008) > 我试过在 mosquitto.conf中加入listener 1883 0.0.0.0 没效果啊 ### 自答 - 解决方法: 在mosquitto.conf中加入如下两句: ``` listener 1883 allow_anonymous true ``` ![title](/api/file/getImage?fileId=6367b0c73c9b99002b000009) ### 注意:开启websockets服务 ![title](/api/file/getImage?fileId=638a22093c9b990013000035) - 修改 /etc/mosquitto/mosquitto.conf , 添加上图中红框中的两句 ``` listener 8888 protocol websockets ```
上一篇:
树莓派中docker安装homeassistant
下一篇:
homeassistant关联易微联APP中的设备
0
赞
30 人读过
新浪微博
微信
腾讯微博
QQ空间
人人网
提交评论
立即登录
, 发表评论.
没有帐号?
立即注册
0
条评论
More...
文档导航
没有帐号? 立即注册