Bug: mqtt server reconnections

Hello,

I have integrated openmqttgateway in my HA installation. It’s been working fine.
However I have one issue I noticed:
Every night I automatically update my server SW stack including the mqtt server.
I notice that when it does happen openmqttgateway will not reconnect and therefore I will loose the gateway functionality for homeassistant.
Could you provide a fix for that so that the gateway will try to automatically reconnect?
If not do you have any advice on how to handle that?
I am running the version 1.8.1 OMG_lilygo_rtl_433_ESP_FSK flavor.
Sincerely

Hello,

It would be interesting to have your gateway serial logs while you do this update process.

For my curiosity, why do you update every night the mqtt server ?

Well actually mqtt server is not updated. However every night I perform backups and before starting I stop the stack that is deployed with docker-compose. So the mqtt server is stopped at this moment leading to the issue.

@1technophile anything I could do about that? Do you know a way to programatically and periodically restart the gateway for example?

You could start by sharing the gateway logs during the restart process

Hello :slight_smile:

Yes, sure, here the logs during the server stack backup operations.

LOGS START

W: failure_number_mqtt: 1

W: failure_number_mqtt: 2

W: failure_number_mqtt: 3

N: Connected to broker
N: [ OMG->MQTT ] topic: home/OMG_lilygo_rtl_433_ESP_FSK/LWT msg: online

T: Enqueue JSON
T: Queue length: 1
N: SYS json: {“uptime”:232,“version”:“v1.8.1”,“mqtt”:true,“serial”:false,“disc”:true,“ohdisc”:false,“env”:“lilygo-rtl_433-fsk”,“freemem”:110316,“mqttp”:“1883”,“mqtts”:false,“mqttv”:false,“msgprc”:19,“msgblck”:0,“msgrcv”:19,“maxq”:19,“cnt_index”:0,“minmem”:54536,“tempc”:53.33,“freestck”:3884,“powermode”:-1,“eth”:false,“rssi”:-57,“SSID”:“Meteor-56CF69BB”,“BSSID”:“04:70:56:CF:69:BD”,“ip”:“192.168.1.104”,“mac”:“14:2B:2F:A6:84:A8”,“modules”:“‘LilyGo_SSD1306’, ‘WebUI’, ‘rtl_433’”,“origin”:“/SYStoMQTT”}
T: Enqueue JSON
T: Queue length: 2
T: Enqueue JSON
T: Queue length: 3
T: Enqueue JSON
T: Queue length: 4
T: Dequeue JSON
N: [ OMG->MQTT ] topic: home/OMG_lilygo_rtl_433_ESP_FSK/SYStoMQTT msg: {“uptime”:232,“version”:“v1.8.1”,“mqtt”:true,“serial”:false,“disc”:true,“ohdisc”:false,“env”:“lilygo-rtl_433-fsk”,“freemem”:110316,“mqttp”:“1883”,“mqtts”:false,“mqttv”:false,“msgprc”:19,“msgblck”:0,“msgrcv”:19,“maxq”:19,“cnt_index”:0,“minmem”:54536,“tempc”:53.33,“freestck”:3884,“powermode”:-1,“eth”:false,“rssi”:-57,“SSID”:“Meteor-56CF69BB”,“BSSID”:“04:70:56:CF:69:BD”,“ip”:“192.168.1.104”,“mac”:“14:2B:2F:A6:84:A8”,“modules”:[“LilyGo_SSD1306”,“WebUI”,“rtl_433”]}
T: Dequeue JSON
V: [ WebUI ] unhandled topic SSD1306toMQTT
N: [ OMG->MQTT ] topic: home/OMG_lilygo_rtl_433_ESP_FSK/SSD1306toMQTT msg: {“onstate”:true,“brightness”:50,“display-flip”:true,“idlelogo”:true,“log-oled”:false,“json-oled”:true}
T: Dequeue JSON
V: [ WebUI ] unhandled topic RFtoMQTT
N: [ OMG->MQTT ] topic: home/OMG_lilygo_rtl_433_ESP_FSK/RFtoMQTT msg: {“active”:3,“frequency”:915,“rssithreshold”:-94,“rssi”:-100,“avgrssi”:-103,“count”:0,“rtl433_stack”:19480,“ookthreshold”:15}
T: Dequeue JSON
V: [ WebUI ] unhandled topic WebUItoMQTT
N: [ OMG->MQTT ] topic: home/OMG_lilygo_rtl_433_ESP_FSK/WebUItoMQTT msg: {“displayMetric”:true,“webUISecure”:true,“displayQueue”:0}

LOGS END

This is confusing because we have the log

N: Connected to broker

However in homeassistant dashboard we have

All other entities used by homeassistant, mainly mqtt integration, have no issues after the server stack restart :face_with_monocle:

After 11 attempts we should try another connection or restart.

Could you wait in your logs until 11+ attempts and share them ?

Well in the meantime I found a solution: I did not persist the mosquitto (MQTT broker) database. So at restart for some reason the gateway would reconnect and some information for homeassistant would be missing.

I solved the issue by persisting mosquitto database.

Sincerely

Good to hear that it works

Yes this is working like a charm now. Many thanks for this great tool :slight_smile:

1 Like