Do Node-red MQTT nodes and CLI mosquitto_pub interfere with each other?

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.

Thanks Julian.

An update:

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.

That sounds like a known problem if you only have one mqtt node. It has been fixed but I am not sure in which version of node red. Possibly only in the new beta so far.

This is likely due to known issue: fix single subscription mqtt node status by Steve-Mcl · Pull Request #3966 · node-red/node-red · GitHub

Will be in V3.1.x

Yup, 3.1 beta seems to fix it, thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.