CONTEXT: Running some test flows between two PC's.
PC1: MQTT Broker with several clients; Client 1 sends messages to Client 2. Clients 1 & 2 very simple five node groups
Exported Client 1 as JSON file and Imported it to PC2.
While the connection of Client 1 on PC1 remained stable, the connection of Client 1 on PC2 kept connecting and disconnecting.
Confirmed that the WiFi connection on PC2 was strong.
Disabled Client 1 on PC2, and rebuilt it exactly from scratch on PC2, the connection now remained stable.
Any suggestions as to why the imported Client 1 on PC2 failed to maintain a stable connection, and the rebuilt Client 1 was stable?
If you copy/paste a flow and you have provided a Client ID in the mqtt broker config then you wll end up with two systems using the same Client ID, which causes the problem you are seeing. Unless you have a good reason then leave the client id blank and node-red will allocate it for you and you will not have this problem.
Actually, you reminded me of something I needed to check. I guess the question is would the Client ID be preserved when imported to PC2, or be given a unique ID by the Broker on the first connection from PC2?
Colin, answered the question the Client ID must have been in conflict; the Broker doesn't automatically assign a new ID.
I don't think it is the broker that allocates an id. If you leave it blank then (I think) the MQTT node allocates an id (probably when it is deployed, but have not checked). If you provide a client id in the config then neither node-red or the broker can change that.
You still have not said whether, where you see the problem, you have provided an id in the config or left it blank.
You didn't need to check the file, just look in the config node. So you (or someone else) told the node to use that id, causing the problem. I just wanted to confirm that this was the problem and not that an auto-generated id is getting exported/imported. So leave it blank and you should not have a problem.