alsuren / mijia-homie

A Homie MQTT bridge for the Xiaomi Mijia 2 hygrometer-thermometer. This repo also serves as the monorepo for a handful of helper crates related to Homie and Bluetooth.
Other
64 stars 14 forks source link

Handle reconnection cleanly #7

Open qwandor-google opened 3 years ago

qwandor-google commented 3 years ago

If the connection is lost to the MQTT broker, publish-mqtt will currently crash due to send errors. We should figure out a way to handle this more cleanly and keep trying to reconnect instead.

qwandor commented 3 years ago

This is also an issue for homie-influx, potentially more so as it is handling multiple connections.

qwandor commented 3 years ago

This is one way mijia-homie can die:

Jan 23 01:16:07 cottagepi mijia-homie[8762]: Trying to connect to Downstairs toilet from status: Unknown
Jan 23 01:17:05 cottagepi mijia-homie[8762]: Error: Mqtt state: Last pingreq isn't acked
Jan 23 01:17:05 cottagepi mijia-homie[8762]: Caused by:
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    0: Mqtt state: Last pingreq isn't acked
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    1: Last pingreq isn't acked
Jan 23 01:17:05 cottagepi mijia-homie[8762]: Stack backtrace:
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    0: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    1: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    2: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    3: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    4: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    5: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    6: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    7: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    8: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:    9: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:   10: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:   11: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:   12: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:   13: <unknown>
Jan 23 01:17:05 cottagepi mijia-homie[8762]:   14: __libc_start_main
Jan 23 01:17:05 cottagepi systemd[1]: mijia-homie.service: Main process exited, code=exited, status=1/FAILURE
Jan 23 01:17:05 cottagepi systemd[1]: mijia-homie.service: Failed with result 'exit-code'.