eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.1k stars 2.4k forks source link

Received duplicate messages in bridge mode #1467

Open tianlongyuan opened 5 years ago

tianlongyuan commented 5 years ago

Use the bridge mode, after the persistent configuration is turned on, the message will be repeated. My mosquitto version is 1.6.4 . This is my mosquitto.conf configuration file.

pid_file /var/run/mosquitto.pid
sys_interval 15
autosave_interval 60
persistence true
persistence_file mosquitto.db
persistence_location /home/mosquitto/
log_dest file /var/log/mosquitto.log
log_type all
connection_messages true
log_timestamp true
log_timestamp_format %Y-%m-%dT%H:%M:%S
allow_anonymous false
password_file /etc/mosquitto/pwfile
connection bridge_37
address 192.168.1.82:1883
topic # both 2 "" ""
cleansession false
notifications true
include_dir /etc/mosquitto/conf.d

This is bridge server log info :

2019-10-22T15:44:29: New connection from 192.168.1.250 on port 1883.
2019-10-22T15:44:29: New client connected from 192.168.1.250 as pushBatchCommandClient (p2, c0, k60, u'user').
2019-10-22T15:44:29: No will message specified.
2019-10-22T15:44:29: Sending CONNACK to pushBatchCommandClient (1, 0)
2019-10-22T15:44:29: Received PUBLISH from pushBatchCommandClient (d0, q2, r0, m1, 'service/msg/Z9DPGYXE', ... (272 bytes))
2019-10-22T15:44:29: Sending PUBREC to pushBatchCommandClient (m1, rc0)
2019-10-22T15:44:29: Received PUBREL from pushBatchCommandClient (Mid: 1)
2019-10-22T15:44:29: Sending PUBCOMP to pushBatchCommandClient (m1)
2019-10-22T15:44:29: Sending PUBLISH to local.iZ2ze4472njheus8qxj91lZ.bridge_37 (d0, q2, r0, m26, 'service/msg/Z9DPGYXE', ... (272 bytes))
2019-10-22T15:44:29: Sending PUBLISH to P327701702000033 (d0, q2, r0, m40, 'service/msg/Z9DPGYXE', ... (272 bytes))
2019-10-22T15:44:29: Received PUBREC from local.iZ2ze4472njheus8qxj91lZ.bridge_37 (Mid: 26)
2019-10-22T15:44:29: Sending PUBREL to local.iZ2ze4472njheus8qxj91lZ.bridge_37 (m26)
2019-10-22T15:44:29: Received PUBCOMP from local.iZ2ze4472njheus8qxj91lZ.bridge_37 (Mid: 26, RC:0)
2019-10-22T15:44:29: Received DISCONNECT from pushBatchCommandClient
2019-10-22T15:44:29: Client pushBatchCommandClient disconnected.
2019-10-22T15:44:29: Received PUBREC from P327701702000033 (Mid: 40)
2019-10-22T15:44:29: Sending PUBREL to P327701702000033 (m40)
2019-10-22T15:44:29: Received PUBCOMP from P327701702000033 (Mid: 40, RC:0)
2019-10-22T15:44:57: Saving in-memory database to /home/mosquitto/mosquitto.db.

This is 192.168.1.82 server info :

2019-10-22T07:43:49: Sending PINGRESP to iZ2ze4472njheus8qxj91lZ.bridge_37
2019-10-22T07:44:30: Received PUBLISH from iZ2ze4472njheus8qxj91lZ.bridge_37 (d0, q2, r0, m26, 'service/msg/Z9DPGYXE', ... (272 bytes))

When my device is shut down and restarted, I will receive the received message continuously. The following is the log information of bridge sending messgae:

2019-10-22T16:09:22: New connection from 10.66.39.82 on port 1883.
2019-10-22T16:09:22: New client connected from 192.168.1.82 as P327701702000033 (p2, c0, k120, u'user').
2019-10-22T16:09:22: Will message specified (63 bytes) (r0, q2).
2019-10-22T16:09:22:    enMessage/en1
2019-10-22T16:09:22: Sending CONNACK to P327701702000033 (1, 0)
2019-10-22T16:09:22: Sending PUBLISH to P327701702000033 (d1, q2, r0, m48, 'service/msg/Z9DPGYXE', ... (272 bytes))
2019-10-22T16:09:22: Sending PUBLISH to P327701702000033 (d0, q2, r0, m49, 'service/msg/Z9DPGYXE', ... (272 bytes))
2019-10-22T16:09:22: Sending PUBLISH to P327701702000033 (d0, q2, r0, m50, 'service/msg/Z9DPGYXE', ... (272 bytes))
2019-10-22T16:09:22: Received PUBREC from P327701702000033 (Mid: 48)
2019-10-22T16:09:22: Sending PUBREL to P327701702000033 (m48)
2019-10-22T16:09:22: Received PUBREC from P327701702000033 (Mid: 49)
2019-10-22T16:09:22: Sending PUBREL to P327701702000033 (m49)
2019-10-22T16:09:23: Received PUBREC from P327701702000033 (Mid: 50)
2019-10-22T16:09:23: Sending PUBREL to P327701702000033 (m50)
2019-10-22T16:09:23: Received SUBSCRIBE from P327701702000033
2019-10-22T16:09:23:    service/msg/Z9DPGYXE (QoS 2)
2019-10-22T16:09:23: P327701702000033 2 service/msg/Z9DPGYXE
2019-10-22T16:09:23: Sending SUBACK to P327701702000033
2019-10-22T16:09:23: Received PUBCOMP from P327701702000033 (Mid: 48, RC:0)
2019-10-22T16:09:23: Received PUBCOMP from P327701702000033 (Mid: 49, RC:0)
2019-10-22T16:09:23: Received PUBCOMP from P327701702000033 (Mid: 50, RC:0)
2019-10-22T16:09:34: Sending PINGREQ to local.iZ2ze4472njheus8qxj91lZ.bridge_37
dankhan-adl commented 5 years ago

I have the same issue. Did you find any working solution?

tianlongyuan commented 4 years ago

We`ll change the mosquitto to emq