The client only deletes messages who have been in the outbox for more than mqtt_delete_expired_messages in the esp_mqtt_task when the state is MQTT_STATE_CONNECTED. This can pose an issue when esp_mqtt_client_enqueue is being used, causing the outbox to grow without bound if the client is not connected.
Code section
mqtt-client.c line 1667
// delete long pending messages
mqtt_delete_expired_messages(client);
Suggestion
The mqtt_delete_expired_messages method could instead be called at the beginning of the client run esp_mqtt_task's while (client->run) loop.
Description
The client only deletes messages who have been in the outbox for more than
mqtt_delete_expired_messages
in theesp_mqtt_task
when the state isMQTT_STATE_CONNECTED
. This can pose an issue whenesp_mqtt_client_enqueue
is being used, causing the outbox to grow without bound if the client is not connected.Code section
mqtt-client.c
line 1667Suggestion
The
mqtt_delete_expired_messages
method could instead be called at the beginning of the client runesp_mqtt_task
'swhile (client->run)
loop.