I'm using Node-red MQTT nodes on two Raspberry Pies as well as publishing at intervals with mosquitto_pub in a shell script.
I keep seeing status Disconnected in Node-red and I suspect that when the command line connection times out, the broker disconnects from Node-red too.
My syslog has thousands of "new connection" and "disconnected" lines.
Broker is Mosquitto on one of the Pies.
Client ID is not specified either in NR or the shell script. I was under the impression this would give parallel connections with unique IDs?
How should I seperate the Node-red and CLI connections?
I'm happy for the CLI one to drop out if it wants, Node-red has to stay connected.
Most MQTT clients should automatically create a random connection id. Having the same id across multiple connections is a common reason for seeing regular connect/disconnect issues.
Other than that, they should all live together in happy harmony! Even publishing to the same topic from multiple clients is no issue - after all, that is exactly what MQTT is for - being a message queue service. Think email for machines. Node-RED certainly creates its own randomised id if you don't specify one.
I would turn up the logging for Mosquitto (by default it logs virtually nothing) for a bit and you may see what the error is.
I confirmed that the script and Node-red mqtt connections do get unique IDs.
Most of the messages in syslog are because when the script exits, it's mqtt connection drops - no surprise there I guess!
I still have a problem with the mqtt-in node dropping the connection.
It seems that sometimes when the flow containing the mqtt node is deployed, it drops the connection and does not reconnect. It reconnects if I restart all flows.
This is on a Pi Zero Two and I have been loading Node-red with a lot of flows from another Pi, not enough to overload it though.