Skip to content

Commit a191366

Browse files
author
Uladzimir Danko
committed
do not subscribe closed clients
1 parent 9c93183 commit a191366

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/handlers/subscribe.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ function addSubs (sub, done) {
155155
func = blockDollarSignTopics(func)
156156
}
157157

158+
if (client.closed || client.broker.closed) {
159+
// a hack, sometimes client.close() or broker.close() happened
160+
// before authenticate() comes back
161+
// we don't continue subscription here
162+
return
163+
}
164+
158165
if (!client.subscriptions[topic]) {
159166
client.subscriptions[topic] = new Subscription(qos, func, rh, rap, nl)
160167
broker.subscribe(topic, func, done)

0 commit comments

Comments
 (0)