kaandesu / vue-paho-mqtt

Easy-to-use MQTT client for Vue 3 with centralized subscription management, type support, and built-in alert notifications.
https://kaandesu.github.io/vue-paho-mqtt/
MIT License
21 stars 3 forks source link

[Feature] Multiple reconnect attempts #93

Open andypotato opened 2 months ago

andypotato commented 2 months ago

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.

maxReconnects: 1 // current behavior (default)
maxReconnects: 3 // try up to 3 times
maxReconnects: -1 // try infinite times (until MQTT is back up)
kaandesu commented 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.