Mosquitto与persitence作为MQTT转发代理

Mosquitto与persitence作为MQTT转发代理,mqtt,mosquitto,messagebroker,Mqtt,Mosquitto,Messagebroker,我们希望在许多OpenWRT网关上使用MOSQUITO MQTT作为消息代理,将“本地”匿名MQTT发布转发到具有授权的中央RabbitMQ/MQTT集群 我们的问题是: MOSQUITO在重新启动时不可靠地转发队列消息(持久性不起作用) 运行MOSQUITO版本:1.4.15 当前配置 这是最后一次测试的配置: port 1883 persistence true persistence_file /mosquitto.db persistence_location /etc/mosquitt

我们希望在许多OpenWRT网关上使用MOSQUITO MQTT作为消息代理,将“本地”匿名MQTT发布转发到具有授权的中央RabbitMQ/MQTT集群

我们的问题是: MOSQUITO在重新启动时不可靠地转发队列消息(持久性不起作用)

运行MOSQUITO版本: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

连接丢失 当我们产生连接丢失(例如断开电缆)并重新建立该连接时,同时收到的消息不会自动从MOSQUITO转发到RabbitMQTT

但是-当在addition中发送新的发布消息时-Mosquetto也会发送排队的消息

莫斯奎托重启 如果我们在连接丢失期间重新启动MOSQUITO,排队的消息将全部丢失-没有持久化选项工作这么长时间

请帮忙
我们尝试了
autosave_interval
QoS 0/1/2
ond
其他选项组合的不同选项,但无论如何,在重新启动MOSQUITO时,所有消息都会丢失-在运行MOSQUITO版本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
并在推送消息后调用保存数据库的请求:

#发布新消息
mosquitto_pub-h localhost-p 1883-t mqtt-m“离线测试100”-q 1
#发送信号保存数据库
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 1

Mosquitto 1.4.x已经很老了,有什么理由你不能尝试2.0.x吗?它是OpenWRT路由器上预装的版本-所以是的-我可能会更新-但它不再由制造商担保-并且在野外已经有约50台设备:-(我检查了OpenWRT的更新流,但它仍然是1.4-因此没有其他选项-1.4.15似乎是最新的1.4.15是从2018年2月开始的,所以你真的需要找到一个解决方案,让你使用更新的东西。网桥上的QOS至少需要为1才能排队,你可能应该添加
cleansion false
&
local_Cleansion false
到bridge配置以确保。Hey@hardillb-就在今天,他们发布了一个新的firmwar;-)这次它的版本是:1.6.x-我将再次进行测试并给出反馈-感谢提示请不要在问题主题中添加“已解决”,只需将此答案标记为已接受即可。