我们希望在许多OpenWRT网关上使用Mosquitto作为消息代理,通过授权将“本地”匿名MQTT发布转发到中央RabbitMQ/MQTT集群。
我们的问题:
Mosquitto在重启时不能可靠地转发队列中的消息(持久性不起作用)
运行蚊子版本: 1.4.15
当前配置
这是最后测试的配置:
port 1883
persistence true
persistence_file /mosquitto.db
persistence_location /etc/mosquitto
autosave_interval 1
autosave_on_changes true
allow_anonymous true
connection iotcluster
address ip:1883
notifications false
keepalive_interval 300
restart_timeout 30
start_type automatic
clientid rabbitmqtt
username user
password password
topic mqtt out 2
try_private true只要所有系统都在运行并在线-一切都按预期工作-任何通过以下方式在本地发布的消息:
mosquitto_pub -h localhost -p 1883 -t mqtt -m "Test-Bridge-Online"将被转发并发布到RabbitMQTT。
连接丢失
当我们产生连接丢失(例如,断开电缆)并重新建立连接时,在此期间接收到的消息不会自动从Mosquitto转发到RabbitMQTT
但是-当发送一个新的发布消息时- Mosquitto也会发送队列中的消息?
蚊子重启
如果我们在连接中断期间重新启动Mosquitto,排队的消息都会丢失--没有任何PERSISTINACE选项工作这么长时间。
请帮帮忙
我们尝试了不同的autosave_interval,QoS 0/1/2和other option combination选项-但无论如何-重启蚊子-所有消息都会丢失-不会以任何方式持久
发布于 2021-05-22 22:00:34
在运行了到蚊子1.6.10版本的更新后,仍然没有成功。
我可以找出主要的问题-数据库在查看时没有保存:
persistence true
persistence_file /mosquitto.db
persistence_location /etc/mosquitto
autosave_interval 1
autosave_on_changes true不确定原因,但无法通过上述设置调用数据库的保存。
数据库在SIG-EXIT时保存,但在推送新消息时不保存。
因此,我将设置更改为:
persistence true
persistence_file /mosquitto.db
persistence_location /etc/mosquitto
autosave_interval 300
autosave_on_changes false并在推送消息后调用保存数据库的请求:
# publish a new message
mosquitto_pub -h localhost -p 1883 -t mqtt -m "Test Offline 100" -q 1
# send signal to save database
killall -SIGUSR1 mosquitto当使用这个时-所有类型的消息都在连接的状态中排队并被传递。
这是最终的配置:
user mosquitto
port 1883
allow_anonymous true
queue_qos0_messages true
persistence true
persistence_file mosquitto.db
persistence_location /etc/mosquitto/
autosave_interval 300
autosave_on_changes false
connection ConName
address remote-ip:1883
bridge_protocol_version mqttv31
clientid ClientName
username user
password password
cleansession false
try_private false
retain_available false
start_type automatic
restart_timeout 60
keepalive_interval 120
notifications true
notifications_local_only true
notification_topic mqtt
topic mqtt out 1https://stackoverflow.com/questions/67634784
复制相似问题