esp-idf-svc icon indicating copy to clipboard operation
esp-idf-svc copied to clipboard

How should MQTT resubscriptions be made for reconnections?

Open reinhardbluelab opened this issue 3 years ago • 1 comments

When the MQTT client has to reconnect and resubscribe on a disconnection, how should this be achieved? The client instance is required to subscribe again, but this is not available (as far as I'm aware of) inside the callback provided to the EspMqttClient.new function. Is there a way to achieve this?

reinhardbluelab avatar Jul 07 '22 11:07 reinhardbluelab

The client reconnects automatically. How I re-subscribe is that I'm listening for Connected events and re-subscribing the client after that.

And yes, you have to subscribe the client from outside the callback.

ivmarkov avatar Jul 07 '22 16:07 ivmarkov