MQTT.js
MQTT.js copied to clipboard
client option [resubscribe:false] doesn't stop the client from resubscribing to broker
- on mqtt broker end I closed the connection of the client
- on mqtt.js client I set resubscribe: false to prevent resubscribe:
var client = mqtt.connect('mqtt://localhost:18888', {
clientId: "coco",
username: user.username,
password: user.password,
protocolVersion: 5,
resubscribe: false,
reconnectPeriod: 3000,
properties: {
requestProblemInformation: true
}
})
- I hope after the connection is closed the client may not try to resubscribe,but that is not the case.
client.subscribe(topic, function (err, granted) {
if (err) {
console.log('subscribe error:', err)
}
})
- And these messages were shown on the console,indicating that the mqtt.js client is resubscribing forever
subscribe error: Error: Connection closed
at /Users/steve/node_modules/mqtt/lib/client.js:124:29
at Array.forEach (<anonymous>)
at flushVolatile (/Users/steve/node_modules/mqtt/lib/client.js:122:24)
at Socket.<anonymous> (/Users/steve/node_modules/mqtt/lib/client.js:358:5)
at Socket.emit (events.js:223:5)
at TCP.<anonymous> (net.js:664:12)
subscribe error: Error: Connection closed
at /Users/steve/node_modules/mqtt/lib/client.js:124:29
at Array.forEach (<anonymous>)
at flushVolatile (/Users/steve/node_modules/mqtt/lib/client.js:122:24)
at Socket.<anonymous> (/Users/steve/node_modules/mqtt/lib/client.js:358:5)
at Socket.emit (events.js:223:5)
at TCP.<anonymous> (net.js:664:12)
subscribe error: Error: Connection closed
at /Users/steve/node_modules/mqtt/lib/client.js:124:29
at Array.forEach (<anonymous>)
at flushVolatile (/Users/steve/node_modules/mqtt/lib/client.js:122:24)
at Socket.<anonymous> (/Users/steve/node_modules/mqtt/lib/client.js:358:5)
at Socket.emit (events.js:223:5)
at TCP.<anonymous> (net.js:664:12)
Am I wrong? 🙋🏻
AB#9191975
This is an automated message to let you know that this issue has gone 365 days without any activity. In order to ensure that we work on issues that still matter, this issue will be closed in 14 days.
If this issue is still important, you can simply comment with a "bump" to keep it open.
Thank you for your contribution.
This issue was automatically closed due to inactivity.