MQTT.js icon indicating copy to clipboard operation
MQTT.js copied to clipboard

client option [resubscribe:false] doesn't stop the client from resubscribing to broker

Open bo-er opened this issue 3 years ago • 1 comments

  • 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

bo-er avatar Jan 24 '21 05:01 bo-er

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.

github-actions[bot] avatar Sep 17 '22 02:09 github-actions[bot]

This issue was automatically closed due to inactivity.

github-actions[bot] avatar Oct 17 '22 02:10 github-actions[bot]