tommy44458 / mqtt-vue-hook

Mqtt-Vue-hook is a TypeScript library that makes it easy to connect to an MQTT broker (supports v5) and manages callback functions for various topics.
https://www.npmjs.com/package/mqtt-vue-hook
MIT License
24 stars 3 forks source link

The keepalive parameter doesn't seem to work #14

Open Sunny0218 opened 9 months ago

Sunny0218 commented 9 months ago

Hello, it's me. The client keeps on trying to reconnect for me when I set keepalive to 0. Is there a way to disable the auto-reconnect mechanism? Also, is there any way to hide the error report in the console? Looking forward to your reply. 1705912929375

tommy44458 commented 9 months ago

Hi @Sunny0218,

I'm happy to see you! If you don't want to try reconnecting to the broker, you can register the 'on-reconnect' event to determine when to disconnect the client (if reconnecting counter > 3 then disconnect it). Additionally, error messages would not be shown in a production environment.

Sunny0218 commented 9 months ago

Hi @Sunny0218,

I'm happy to see you! If you don't want to try reconnecting to the broker, you can register the 'on-reconnect' event to determine when to disconnect the client (if reconnecting counter > 3 then disconnect it). Additionally, error messages would not be shown in a production environment.

@tommy44458 Thank you for your reply. I would like to ask one more question based on your reply: Is the reconnect mechanism disconnected by the method "mqttHook.disconnect()"?

tommy44458 commented 9 months ago

@Sunny0218 Yes, that's right.