I've been playing with Node-Red for just a little while. I have a flow that reads from SQLite and outputs to MQTT. This was working fine for several months but at some point recently the MQTT Out Node started playing up.
When deployed, it connects for a little while, then disconnects, then reconnects again.
It loops through the 3 states continuously, staying in each state for a few seconds at a time. When connected, it does work, but I miss many messages during the Disconnected and Connecting periods.
Any idea why this is happening now when it wasn't in the past?
No obvious errors on the console. But then I'm still trying to work out how to get it to log details. I do have a few other publishers on the network and I don't seem to be losing any messages form them. Just the Node-Red flows.
This sounds as if you might have multiple clients specifying the same client id. Make sure each one has a different id, or you leave it blank. Also make sure that in each node-red (if you have multiple) that you only have one config node for each MQTT broker (or at least that again they do not specify the same client id).
If it is not that then as suggested, you should look at the mosquitto log (if it is mosquitto you are using).
If you don't set a client id, a random identifier will be generated by the MQTT client library, usually a combination of host/username and the current timestamp, if I remember correctly. That id will change with every reconnect.
However, if you rely on message QoS levels 1 or 2, or a last-will topic, you should set a unique fixed client id yourself to ensure consistent behavior across reconnects/connection failures.