Is there a mechanism for reconnecting to an mqtt broker using the same network? I am using the Amazon FreeRTOS on esp32-wrover-kit and I’m having an issue with reconnecting if the device fails to send PINGREQ. In this case, where the device is still connected to the network, but it cannot send PINGREQ to the mqtt server I register a callback function for mqtt disconnect.
In the mqtt disconnect callback I am able to connect again but I believe it creates a new network and mqtt broker because I notice that my heap size goes down considerably. So on subsequent disconnects and attempts to re-establish a connection, there is not enough heap memory to allocate resources for the network connection. Is there a way to re-use the network and mqtt connection?