MQTT Reconnect

Hi All,

I had a (hopefully) quick question regarding the MQTT binding that I hope someone can help with. I have a few Halloween props using MQTT to send triggers to openHAB. OH then decides what to send back to them based on some variables, such as timers from the front door. The problem I’m seeing is that the props only turn on during certain parts of the day/evening and I have to restart openHAB once they are on to get everything working. If I don’t restart then it doesn’t work. What I’m wondering is:

I know OH creates the connection on startup but what are the reconnect settings (if any)? Example, both are communicating and I restart a prop or shut down/restart for a few minutes and everything is okay. But if the prop is shut down for long periods and OH stays on then I need to restart OH to re-establish communication.

Is there a way for OH to check every X minutes to see if a broker is alive?

Thanks in advance,

The binding does that automatically
You can check the logs. Turn off your broker and turn it back on. You will see openHAB disconnecting, trying to reconnect and reconnecting.

openHAB and the prop don’t communicte directly. The broker is in the middle. openHAB sends an mqtt message and doesn’t care if it is received or not by the subscriber (your prop)

Have you checked that your props reconnect properly and a “long period”?

Thanks for that. I think I now know what was happening after looking at the logs. It does show that it is trying to reconnect.

So what was happening?

So I think the problem I was seeing is that I have numerous props using this method and was restarting openHAB too many times when some props were on and others were off. I kept repeating the same cycle and missed the log entries to help me isolate the issue. Basically, if openHAB didn’t see them on initial startup it didn’t know to try to reconnect to them. Once I started everything at the same time and then started openHAB after they all connected. I could then power off props and openHAB would reconnect when they came back on.