gysmo38 / mitsubishi2MQTT

Mitsubishi to MQTT with ESP8266 module
GNU Lesser General Public License v2.1
371 stars 133 forks source link

use exponential backoff for retrying heatpump connection #176

Closed mbbush closed 1 year ago

mbbush commented 1 year ago

Fixes #159

I noticed that there was already code which retried the connection to the heatpump when it was disconnected, but it had a bug where it never reset the number of tries, so if it tried twice on Tuesday, then successfully reconnected, tried twice on Thursday, and successfully reconnected, and tried once on Friday, with the default count of 5 it would then give up until restarted.

Now it resets the number of tries after each successful connection. It also never completely gives up trying to connect.

I also updated the logic which delays the retries to use exponential backoff instead of a constant retry rate. Exponential backoff is a common retry strategy that seemed easy enough to apply here.

freddieleeman commented 1 year ago

I have experienced this issue too. @gysmo38, please merge and rebuild binary for easy update.