From 7eb8cb31434cdd0cb7d3f07b7875aeb82bd482d1 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Thu, 14 Nov 2013 16:13:24 +0100 Subject: [PATCH] Destroy the gateway connection on error, so reconnection works also when the connection is dropped instead of closed. --- lib/apnagent/agent/live.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/apnagent/agent/live.js b/lib/apnagent/agent/live.js index 2aa5fca..c7866ab 100644 --- a/lib/apnagent/agent/live.js +++ b/lib/apnagent/agent/live.js @@ -154,6 +154,9 @@ Agent.prototype.connect = function (cb) { // emit errors; gateway.on('error', function (err) { debug('(gateway) error: %s', err.message || 'Unspecified Error'); + if (self.gateway) { + self.gateway.destroy(); + } self.emit('gateway:error', err); });