MQTT Time Out / Random Disconnect

Hello Folks,

I have recently came across an issue with the MQTT nodes on node Red.

Randomly the mqtt node will disconnect requiring a restart or reboot of Node Red- I was wondering if this has to do with the keep alive time or if its something else but similar?

Any advice would be much appreciated,

Thank you

Odd. The connection should recover automatically.

  • What version of node-red are you using?
  • What version of node-js are you using?
  • What broker are you using and where is your broker? (local? Lan? Cloud?)
  • Have you specified a client id in your MQTT config node? If so - is this necessary? is it duplicated elsewhere?

When it is disconnected, do you wait at least 1 minute for reconnection?

node.js V12.18.2
node red V1.2.7
AWS broker, lan then through to the cloud.
No client id`s all left blank.

yes I do , but they disconnect and stay off which is the concern.

It may be related to the AWS broker.
You could test this by connecting to a local broker & rebooting it to see if node-red reconnects.

Have you considered upgrading to latest V2 and node-js 14?

The latest mqtt nodes can be issued a connect and disconnect action. It might dig you out of a hole.

Thank you,

Could you explain what you mean by a local broker? The AWS broker we have is online, so we submit everything via lan to a router which speak to the aws server on line?

I assume the connect reconnect command is on node red, does the mqtt node also tell me when it disconnects?

I mean local to your node-red (i.e. mosquitto installed on the same server or a device on your LAN - e.g NOT AWS)

Yes, you would issue a msg to an MQTT node, formatted to tell the node-red client connection to the broker to connect/disconnect (which you can of course automate)

Yes, you can cpature the status of a node using a status node. Therefore you can point a status node at an MQTT node & it will send a message everytime the status of that node changes (essentially providing you with a means to understand the state of the MQTT connection & therefore a means to automate a reconnection)

I suggest updating node-red to the latest, there have been significant changes to the MQTT nodes so that in itself may fix or change the symptom.

May I ask if the keep alive function on the mqtt node would do anything? I was thinking perhaps the mqtt is timing out due to inactivity hence the keep alive could improve it?

I had a Tasmota MQTT configured device which had a bad connection to the 230V supply, it was going on and off many times a day (in batches) due to the intermittent connection. The Node-RED MQTT connection always reconnected.

The MQTT device was installed before April 2020, not sure which version of Node-RED, but this was well before V2 was released, and I had seen no problems. As to the intermittent connection, not sure when that began as I only started tracking the connections last September, and that was for a completely different reason. It was only when I created this flow that I found the problem.

HTH

How exactly is this done? The mqtt node doesn`t allow any reconnection command, only the passing of signals to the specific topic ?

It's documented in the built in help

But first, I'll refer you back to my first post...

Emphasis on this "The latest mqtt nodes can be issued a connect and disconnect action"

Okay , I gathered that, however checking in the palette there doesn`t seem to be a latest node that is capable of this - do you have any node package suggestions? Thank you.

You have to upgrade node-red to v2.x latest. Then you get the new capabilities.

And, as I said, it is worth doing that first and making sure it still fails.