1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Catch mqtt socket write error after disconnect

Part of #155
This commit is contained in:
Nick O'Leary 2014-02-19 21:30:46 +00:00
parent d8f2f24b44
commit b4ef1d354d

View File

@ -79,7 +79,10 @@ MQTTClient.prototype.connect = function(options) {
var now = (new Date()).getTime(); var now = (new Date()).getTime();
if (now - self.lastOutbound > self.options.keepalive*500 || now - self.lastInbound > self.options.keepalive*500) { if (now - self.lastOutbound > self.options.keepalive*500 || now - self.lastInbound > self.options.keepalive*500) {
if (self.pingOutstanding) { if (self.pingOutstanding) {
try {
self.client.disconnect(); self.client.disconnect();
} catch (err) {
}
} else { } else {
self.lastOutbound = (new Date()).getTime(); self.lastOutbound = (new Date()).getTime();
self.lastInbound = (new Date()).getTime(); self.lastInbound = (new Date()).getTime();
@ -216,7 +219,10 @@ MQTTClient.prototype.disconnect = function() {
var self = this; var self = this;
if (this.connected) { if (this.connected) {
this.connected = false; this.connected = false;
try {
this.client.disconnect(); this.client.disconnect();
} catch(err) {
}
} }
} }
MQTTClient.prototype.isConnected = function() { MQTTClient.prototype.isConnected = function() {