I guess this is intended behavior and not a bug (you want to exclude broken config at startup) but in my particular setup it just happens to be an often situation.
My question is do you maybe have an elegant solution to the issue? Preferably to start the reconnect helper at startup.
I’d prefer to avoid hacks outside of OH but in the end if there is no easy solution I’ll create a dependency on OH startup script to wait till MQTT is ready before it allows the start.
You can’t start the reconnect helper at startup, because no broker connection exists.
The problem you’re hitting is that there is no retry logic on the initial creation of a broker connection. You could create a request for such an enhancement.
The best solution is to have your broker ready before starting OH.
My question was about “best solution is to have your broker ready”, because I cannot do that. I ended using external mqtt server which seems to work ok when rebooting the system.
I will open an issue next week, but I don’t know if the problem is the binding for not retrying, or opehab for not “priorize” embedded server.
For anyone interested in a solution external to OH what I did to solve it:
Generate key pair:
ssh-keygen -t rsa -f openhab.id_rsa
Add a user (openhabMQTT) that can login into karaf with a key and is part of a new group (MQTTmanager). Please follow https://karaf.apache.org/manual/latest/security.
Add to etc/keys.properties:
openhabMQTT=AAAAB3.........xyz,MQTTmanager
Mind to replace “AAAAB3…xyz” with your real public part of the key (openhab.id_rsa.pub) you intend to use to authenticate.
Allow users in MQTTmanager group to do bundle:restart by adding to etc/org.apache.karaf.command.acl.bundle.cfg the following line:
restart = MQTTmanager
Trigger the below command whenever your MQTT server is ready: