Mosquitto出版问题?

时间:2018-03-22 19:31:25

标签: mqtt mosquitto

我在我的Ubuntu 16.04服务器上启动并运行了Mosquitto。 我在2部手机上使用Owntracks并让他们订阅了另一部话题。

然后在上周的某个时间,两部手机都丢失了另一个主题,紧接着电话2没有连接到MQTT就日志而言,但电话仍然报告为已连接。

然后今天我使用webhooks在端口8083上添加了一个新的监听器。我能够连接网络管理界面并订阅手机1的主题。

我订阅了CLI,看看我是否可以通过web界面与phone 2的用户进行一些故障排除。当我断开连接并尝试重新连接(同时使用电话2和电话1用户)时,我无法重新连接到MQTT。

我重新启动了MQTT并且我能够重新建立连接,但现在当我发布任何内容时,订阅者中没有任何内容。电话1不再显示,即使CLI无法正常发布。

我认为我的配置中已经破坏了一些东西。

mosquitto.conf

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/
persistence_file mosquitto.db
log_dest file /var/log/mosquitto/mosquitto.log
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
password_file /etc/mosquitto/pwfile
acl_file /etc/mosquitto/aclfile.acl

#Internal Listener
listener 1883
allow_anonymous false

#External Listener
#listener 8883
#allow_anonymous false
#certfile /etc/letsencrypt/live/home.fqdn.com/cert.pem
#cafile /etc/letsencrypt/live/home.fqdn.com/chain.pem
#keyfile /etc/letsencrypt/live/home.fqdn.com/privkey.pem

#Webhooks Listener
listener 8083
protocol websockets
certfile /etc/letsencrypt/live/home.fqdn.com/cert.pem
cafile /etc/letsencrypt/live/home.fqdn.com/chain.pem
keyfile /etc/letsencrypt/live/home.fqdn.com/privkey.pem

aclfile.acl

# This affects access control for clients with no username.
topic read $SYS/#

# This only affects clients with username "phone1".
topic owntracks/phone1/phone-1
topic read owntracks/phone2/phone-2

# This only affects clients with username "phone2".
topic owntracks/phone2/phone-2
topic read owntracks/phone1/phone-1

# This affects all clients.
pattern write $SYS/broker/connection/%c/state

1 个答案:

答案 0 :(得分:0)

在每个topic / pattern阻止之前,应该有一个user条目来说明他们申请的用户:

# This affects access control for clients with no username.
topic read $SYS/#

# This only affects clients with username "phone1".
user phone1
topic owntracks/phone1/phone-1
topic read owntracks/phone2/phone-2

# This only affects clients with username "phone2".
user phone2
topic owntracks/phone2/phone-2
topic read owntracks/phone1/phone-1

# This affects all clients.
pattern write $SYS/broker/connection/%c/state