espressif / esp-mqtt

ESP32 mqtt component
Apache License 2.0
591 stars 254 forks source link

Expired messages only delete when connected (IDFGH-12831) #278

Closed Totrasmek closed 1 month ago

Totrasmek commented 1 month ago

Description

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.