-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
MQTTjs Version
5.7.3
Broker
mosquitto
Environment
NodeJS
Description
While calling the publish method on a connected client the Error: client disconnecting is thrown by the lib.
The reason for this is that the Client.disconnecting flag is not reset to false after the Client.end method is finished.
Workaround: calling the reconnect method instead of the connect method, cause the Client.disconnecting flag is reset to false there
Minimal Reproduction
- create a Client with mqtt.connect method using the option manualConnect
- call the Client method connect
- after connect event is triggered, call the Client end method
- after close event is triggered, call the Client connect method
- after connect event is triggered, call the Client publish method
- -> Error: client disconnecting is thrown
Debug logs
Error: client disconnecting
at MqttClient._checkDisconnecting (/home/scBot/kaeser-utils/node_modules/mqtt/build/lib/client.js:764:36)
at MqttClient.publish (/home/scBot/kaeser-utils/node_modules/mqtt/build/lib/client.js:330:18)
at MqttClient. (/home/scBot/kaeser-utils/ipc/test.js:29:20)
at Object.onceWrapper (node:events:628:26)
at MqttClient.emit (node:events:525:35)
at MqttClient._onConnect (/home/scBot/kaeser-utils/node_modules/mqtt/build/lib/client.js:1078:18)
at handleConnack (/home/scBot/kaeser-utils/node_modules/mqtt/build/lib/handlers/connack.js:39:29)
at handle (/home/scBot/kaeser-utils/node_modules/mqtt/build/lib/handlers/index.js:44:35)
at work (/home/scBot/kaeser-utils/node_modules/mqtt/build/lib/client.js:221:40)
at Writable.writable._write (/home/scBot/kaeser-utils/node_modules/mqtt/build/lib/client.js:246:13)