MQTT / ZwaveJSUI disconnection

@pierre-gilles, I had another disconnection of zwavejs from the MQTT broker. My wife wasn’t happy because the garage door wouldn’t open anymore!

So there was nothing abnormal in the logs — except that the scene wasn’t working because of the MQTT broker disconnection.

2025-02-15T18:24:49+0100 <warn> scene.executeActions.js:37 (executeAction) ServiceNotConfiguredError: MQTT is not configured.
    at ZwaveJSUIHandler.publish (/src/server/services/zwavejs-ui/lib/zwaveJSUI.publish.js:12:11)
    at ZwaveJSUIHandler.setValue (/src/server/services/zwavejs-ui/lib/zwaveJSUI.setValue.js:97:10)
    at DeviceManager.setValue (/src/server/lib/device/device.setValue.js:21:24)
    at Object.device.set-value (/src/server/lib/scene/scene.actions.js:66:24)
    at executeAction (/src/server/lib/scene/scene.executeActions.js:32:35)
    at /src/server/lib/scene/scene.executeActions.js:66:13
    at tryCatcher (/src/server/node_modules/bluebird/js/release/util.js:16:23)
    at MappingPromiseArray._promiseFulfilled (/src/server/node_modules/bluebird/js/release/map.js:68:38)
    at MappingPromiseArray.PromiseArray._iterate (/src/server/node_modules/bluebird/js/release/promise_array.js:115:31)
    at MappingPromiseArray.init (/src/server/node_modules/bluebird/js/release/promise_array.js:79:10)
    at MappingPromiseArray._asyncInit (/src/server/node_modules/bluebird/js/release/map.js:37:10)
    at _drainQueueStep (/src/server/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/src/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/src/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues (/src/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:476:21)

After saving the config everything was OK.

I checked my mqtt container and it had been updated 16 hours earlier.
image

So, I tried stopping the container manually and the issue occurred. So if Gladys loses the connection because the container is stopped or updated… Gladys does not reconnect automatically.
I hadn’t noticed that I had used the latest version. I’ll block it to prevent any automatic updates on this container.

Phew, well I’m not the only one.
My external MQTT Docker updated itself last night at my place (2.0.20 to 2.0.20) and the connection didn’t come back on its own.
But that’s actually a different problem because I also have zwaveJS that didn’t restart, and I noticed it tonight.
To get everything going again, I had to go into the MQTT integration config and save, then into the zwaveJS config and save as well.
I should point out that my HA and Jeedom had no problems and continued quite happily to send data to MQTT.
Another point: I have an MQTT device to collect info sent by Jeedom (mainly téléinfo) and some features that listen to custom topics. And unfortunately no data from the custom topics was coming through.
I had to change a value in one of the features and save for everything to return to normal.

I’m available if you need to dig deeper and debug the setup — you’ll just need to guide me on what info to collect.

I’ve pinned it to version 2.0.20 but it’s already the 3rd update running on that same version so I’m not sure that’s the solution…

Hi @_Will_71 and @mutmut, thanks for the feedback!

In the case of Z-WaveJS, are you able to reproduce the bug manually? If you restart the Mosquitto container, does the disconnection occur or

Yes, I can reproduce it if I stop the container manually with the command docker stop … and then start it again with the command docker start …

Ok, I created a GitHub issue :

I think I see what’s happening, @Terdious had already noticed that, but there was simply code in the current implementation that disconnected Gladys in case of connection loss… :expressionless:

I removed that whole part, and took the opportunity to migrate to MQTT.js 5 which is entirely rewritten in TypeScript and should be more stable.

I ran tests, and it works much better!

The PR:

2 Likes

Hello, reproduced just now by stopping the Docker container and then starting it again.

Merged PR that will be included in the next Gladys release!

1 Like

This fix is available in Gladys Assistant 4.54.0:

1 Like