我在Debian 9上安装了Mosquetto
apt-get install mosquitto mosquitto-clients
重新启动
服务mosquitto重新启动
测试了它
mosquitto_pub -d -t My/Topic2 -m "Hello MQTT"
无错误消息
创建了密码
mosquitto_passwd -c /etc/mosquitto/passwd myUsername
创建了ACL文件
touch /etc/mosquitto/aclfile
nano /etc/mosquitto/aclfile
使用此内容:
# This affects access control for clients with no username.
topic read myTopic/#
# This only affects clients with username "myUsername".
user myUsername
topic myTopic/#
# This affects all clients.
pattern write $SYS/broker/connection/%c/state
将acl\u文件的路径插入到此文件
nano /etc/mosquitto/mosquitto.conf
acl_file /etc/mosquitto/aclfile
password_file /etc/mosquitto/passwd
因此,计划是用户“myUsername”可以在“myTopic”中发布,而所有其他用户(包括来宾)只能阅读。
我已经在其他服务器上运行了此配置,但在这种情况下出现了问题
第一次测试时,我忘记将password\u文件路径添加到mosquitto。形态
并得到错误:如果我想发布,连接被拒绝
如果我只想订阅
好的,我解决了这个问题,但现在我可以不使用用户名/密码发布
对于corse,我重新启动了:
service mosquitto restart
所以如果我发送
mosquitto_pub -d -t myTopic/test -m "Access denied is expected"
我没有发现错误,看起来消息发布了
如果我打开第二个shell(也从远程机器打开)
我可以订阅
mosquitto_sub -d -t myTopic/test
但是,如果我将某个内容发布到此主题,则不会收到任何内容(Ping正在工作)
对我的两个问题有什么想法吗?
PS:我不是Linux专业人士
因此,如果您需要更多信息,请向我提供正确的信息如何获取这些信息
编辑:如果我使用
ps -efc
这是mosquitto的唯一入口
mosquit+ 736 1 TS 19 21:36 ? 00:00:02 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
在日志中
nano /var/log/mosquitto/mosquitto.log
我明白了
ACL denying access to client with dangerous client id "mosqpub/7977-Debian-93-"
ACL denying access to client with dangerous client id "mosqpub/356-h2700629"
但对于谷歌来说,这应该已经在去年解决了
我正在使用Mosquetto版本1.4.10