MQTT connects, established, failed over and over, and not sure why

Not sure where else to ask, and this may not be the right place but thought I’d give it a shot:

I’m using RTL_433 to monitor my weather station, I have two pi’s (in the process of moving the monitoring) that are reading the weather station. Both talk to the same MQTT server, when both are running I see the following over and over.

MQTT Connected…
MQTT Connection established.
MQTT Connection failed…

This is my first attempt at using MQTT and with the single PI running everything works perfect, and I will be going back to the single PI soon, but in the long run I do plan on having multiple PI’s talking to the MQTT server for different reasons and trying to figure out if this is an issue.

Seems like it’s not as much, but I do get data from both of the PI’s. I’m not sure why this is occurring, can you not have multiple things talking to same MQTT server? is it just something in the way the RTL_433 works? Is this just normal?

Found your post via google search as I’m having the same issue with rtl_433. I’m running mine via docker in unraid.

Just as yours, mine is sending data to my MQTT broker just fine (until it doesn’t). Seems to be stable for anywhere between a few minutes and a few days, but eventually crashes. I restart of the docker fixes it again. I had no trouble when running in a linux VM, this all started with the docker image.

Anyhow, to answer your question re: multiple things talking to your MQTT broker- that’s basically what MQTT is for! It is a message broker for all sorts of devices and there should be no problem for hundreds of devices to be sending and reading messages/topics.

The RTL_433 behavior you’re seeing in logs shouldn’t be normal, but I wouldn’t worry too much about it if it remains stable. I’m assuming it’s what is eventually causing my crashes, but I can’t be sure.

I spent a little time today digging into this and found my issue, maybe similar for you:

I’m using the RTL_433 docker via unraid and noticed (by using the “advanced view” when editing the docker template) that I was passing a post argument of '-F MQTT…" (i.e. establishing the MQTT connection) in addition to using the rtl_433.conf file to pass that same mqtt connection command. I simply removed that post argument establishing the second mqtt connection and it resolved my issue.

Essentially, I was connecting to my MQTT broker twice with the same client ID. This caused MQTT to see a new connection with that same device ID (generated by RTL_433) and say “oh hey, you were already connected from a different port- I’ll close that old connection and establish you on a new one”. This went on and on every few seconds as each of the two mqtt connections I made alternated trying to send my MQTT broker data. Each time mqtt saw the “new” connection and closed it, the RTL_433 docker incremented the port number that it would try to connect with the next time. Eventually, this was crashing the RTL_433 docker.

Anyhow, I’d suggest looking at your MQTT broker logs to see if you see the same “already connected, closing the old connection” messages- that would tell you that you’re trying to connect multiple times using the same client id.

This makes a lot of sense, and given that I was trying to set up a second PI to do the exact same thing as the first PI I’m going to say this was my issue.

I have since moved to the new pi, and no longer have any issues.