Open andypotato opened 2 months ago
Hey there, I see this can be a useful feature. I'll return to this after checking the #94 discussion, where we might implement a custom reconnect callback, where this feature mentioned above can also reside configurable. I'll not be available for at least in the next few days, but I'll assign myself to this issue once I am. Thanks again for the issue.
Currently your library supports automatically reconnecting to the MQTT broker. However there will be only ever be one reconnection attempt.
If the reconnection attempt fails, the library will stop reconnecting and not try again. This may be the desired behavior in some cases, but in many real-world cases you would expect to retry reconnecting until the MQTT becomes available again.
How about a configuration parameter
maxReconnects
which can either take a number (for example "3") for maximum of 3 reconnection attempts. If you set it to "-1", then it will try infinite times to reconnect.