Open jbaramidze opened 3 years ago
To help with reproducing, client codes: C1:
import mqtt from "mqtt";
const LOCAL_URL = "ws://localhost:6423/mqtt";
var client = mqtt.connect(LOCAL_URL, {clientId: `3:someString`, username: "3", clean: false})
client.on('connect', function (pack) {
client.publish(`broadcast/5`, `HELLO ${process.argv[2]}`, {retain: true, qos: 2});
});
C2:
import mqtt from "mqtt";
const LOCAL_URL = "ws://localhost:6423/mqtt";
var client = mqtt.connect(LOCAL_URL, {clientId: `2:someString`, username: "2", clean: false})
client.on('connect', function (pack) {
client.subscribe(`broadcast/5`, {qos: 2}, function (err, s) {
console.log("Error on subscribe: ", err);
});
});
@jbaramidze Are you able to submit a PR to fix the issue? It seems you have found the line causing the bug
System Information
Describe the bug aedes-persistence-redis crashes when trying to send retained message of QoS=2
To Reproduce
aedes-persistence-redis
persistence layer. I have usedmqtt-cli
package for it, with the following config:C1
(non-clean session), and send message to any topic with{retain: true, qos: 2}
C1
C2
(non-clean session), and subscribe to a topic used above with{qos: 2}
aedes-persistence-redis
with errorERROR: unknown key
Expected behavior Should not crash
Additional context After debugging a little, it seems that it crashes when it's trying to send
PubRel
packet of the retained message. Aedes invokesRedisPersistence.prototype.outgoingUpdate
, which callsaugmentWithBrokerData
. Inside this function,var key = that.messageIdCache.get(messageIdKey)
returnsundefined
, which causes the crash