diff --git a/lib/handlers/subscribe.js b/lib/handlers/subscribe.js index 24704274..2ae0a467 100644 --- a/lib/handlers/subscribe.js +++ b/lib/handlers/subscribe.js @@ -155,6 +155,13 @@ function addSubs (sub, done) { func = blockDollarSignTopics(func) } + if (client.closed || client.broker.closed) { + // a hack, sometimes client.close() or broker.close() happened + // before authenticate() comes back + // we don't continue subscription here + return + } + if (!client.subscriptions[topic]) { client.subscriptions[topic] = new Subscription(qos, func, rh, rap, nl) broker.subscribe(topic, func, done)