node-red: MQTT-Node: Messages are lost on connection problems, despite QOS-Level 1
What are the steps to reproduce?
Generate this simple testflow
Subscripe topic on another machine via
mosquitto_sub -h <MQTT Server-Address> -t /testtopic -q 1
In the following 0;19 means 0am and 19 minutes. Thats just for better redoing the steps.
0:19 Click inject. You’ll see that you receive the timestamp.
0:20 On NodeRed host do
sudo iptables -A OUTPUT -d <IP of MQTT Server>/32 -j DROP
to simulate network problems.
Click 5 times inject node.
Wait until MQTT Node shows connections problems
0:21 click 5 times inject node
0:22 do sudo iptables -D OUTPUT -d <IP of MQTT Server>/32 -j DROP
to reestablish connection.
Don’t wait. Immediately after executing that command click inject Node 5 times.
What happens?
MQTT Client shows
1612739965989 --> 0:19
1612740005045 --> 0:20
1612740006033 --> 0:20
1612740006913 --> 0:20
1612740007707 --> 0:20
1612740008476 --> 0:20
So a lot of messages are lost. It seems all messages are lost that are received while not in connected state.
What do you expect to happen?
I expected that all messages are received. Maybe duplicate because of QOS1, but definitely no dropped messages. Or if dropped messages, then there should be thrown an error with you can catch by a Catch-Node.
Please tell us about your environment:
- Node-RED version: v1.2.6
- Node.js version: v12.20.0
- npm version:
- Platform/OS: Linux 5.4.79-v7l+ arm LE
- Browser: Firefox
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 31 (14 by maintainers)
I think it depends. With MQTT QOS Level 1 it is desired that messages are delivered at least once, so these should be buffered. QOS Level 0 messages have no check if they arrive, so these messages could be dropped when broker is offline. If messages are always dropped when broker connection has some trouble, than QOS Level 1 and 2 wouldn’t be required at all.