Issue with MQTT reconnecting to broker if wifi connection goes down (con't)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello vik86

As a follow on to this thread: Issue with MQTT reconnecting to broker if wifi connection goes down

I'm also trying to make the same logic work. When disconnected, I deinit and free mqtt_object and do some other stuff. Then I recreate it and try to connect. However there seems to be a memory leak, I think it might be related with the linked list that the session creates. Is there a way to easily delete all the data related to mqtt connection? Here is the code I used for deinit :

  mqtt_connection_t *conn = (mqtt_connection_t*) mqtt_object;

  wiced_rtos_deregister_timed_event( &conn->heartbeat.timer );

  mqtt_connection_deinit(conn);

  wiced_mqtt_deinit(mqtt_object);

  free( mqtt_object );

Thanks

0 Likes
1 Reply
JeGu_2199941
Level 5
Level 5
25 likes received 10 likes received 10 likes given

@ mqtt_manager.c : bottom of wiced_result_t mqtt_manager( mqtt_event_t event, void *args, mqtt_connection_t *conn )

case MQTT_EVENT_CONNECTION_CLOSE:

        {

            /* TODO : add implementations here, or add fall-through to default */

            mqtt_manager_heartbeat_recv_reset( &conn->heartbeat );

            mqtt_connection_deinit(conn);

        }

will this help?