mirror of https://github.com/node-red/node-red.git
Handle duplicate PUBREL
Fixes #138 If the connection to a broker is lost mid qos 2 flow, there is a window where we have processed the PUBREL, released the message and deleted it from our store, but not sent the PUBCOMP. When the connection is re-established, and the PUBREL is resent by the broker, we assume the message still exists - and hit the error reported. The fix is to check the message is valid before trying to process it. We send the PUBCOMP to complete the flow regardless.pull/139/head
parent
6b3010f95b
commit
79aeeea640
|
@ -130,8 +130,10 @@ MQTTClient.prototype.connect = function(options) {
|
|||
client.on('pubrel',function(packet) {
|
||||
self.lastInbound = (new Date()).getTime()
|
||||
var p = self.inboundMessages[packet.messageId];
|
||||
if (p) {
|
||||
self.emit('message',p.topic,p.payload,p.qos,p.retain);
|
||||
delete self.inboundMessages[packet.messageId];
|
||||
}
|
||||
self.lastOutbound = (new Date()).getTime()
|
||||
self.client.pubcomp(packet);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue