I've noticed on several NodeRed instances (in Raspberries, on Ubuntu and in Docker) that changes in DNS are not reflected in NodeRed.
What I mean is: I've changed the A-record of a MQTT message broker and expect that witin a certain time (TTL) NodeRed will try to connect tho the MQTT Brokers' new IP address.
But this doesn't happen even not after a few days.
I've compared this to other services like IOT devices and Telegraf and they correctly change their connection after the TTL.
When I restart the NodeRed Service the problem is solved.
What can I do to correct this?
This is working exactly as expected.
An MQTT connection is a persistent connection, that means it is made once when the client is started and unless there is a problem that causes the connection to be dropped (e.g network outage, client or broker restarted) it will stay open.
This means the client will do a DNS lookup once at the start and then not need to do it again until it needs to recreate the connection, which under normal operations will be never.
The other services you mention are either not using MQTT (e.g. HTTP which would make a new connection for every request) or have other reasons for restarting the MQTT connection.
To add to what Ben has said, the newer versions of MQTT nodes now have the ability to be commanded (via
msg.action) to disconnect/connect..
If you are aware of an impending DNS change, prepare 2 inject nodes to manually disconnect/re-connect.
Or if you have no control over when DNS changes occur, you could monitor your broker and issue a disconnect then connect action in an automated fashion.
Thanks @hardillb Good to know this. Strange is that my IOT devices don't seem to have that problem even though they also use MQTT. Obviously a different implementation then.
Thanks for the tips @Steve-Mcl This is very helpful.
The most likely thing is either the IoT devices are going into low power mode and resetting the connection when they power back up or loosing network connection for some reason.
Understand what you mean and in low-power devices very likely but in my case these IOT devices are 24/7 active (no LoRa or so).
Anyway.. Case solved.
Thanks for your time and effort, Ben..
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.