eclipse/paho.mqtt.c

MQTT client has a long delay time to retransmit in-flight message when using MQTTCLIENT_PERSISTENCE_DEFAULT flag

yxjeag opened this issue · 0 comments

Describe the bug
I init the client like this:

void MqttClient::Init(const std::string& iot_device_name, const std::string& iot_addr, const std::string& mqtt_client_id) {
	if (MQTTAsync_create(&client_, iot_addr.c_str(), mqtt_client_id.c_str(),MQTTCLIENT_PERSISTENCE_DEFAULT, ".cache/persistence") != MQTTASYNC_SUCCESS) {
    LOG(FATAL) << "MQTTAsync_create failed. ClientId=" << mqtt_client_id<< " IotAddr=" << iot_addr;
  }
}

I want to ensure the message delivery which QoS > 0. So I persist the in-flight message by using flag MQTTCLIENT_PERSISTENCE_DEFAULT to create client, but foud the persistence directory exsited the cached message file not retransmist immediately when mqtt client reconnected unil I kill the process then reboot it. The delay time even more than 7 days according to our monitor data.

To Reproduce
My mqtt application runs on moving vehicle which network conditions are constantly changing. I didn't reproduce the issue by local environment honestly. But this issue occured on our production enviroment and I found the so long delay time by monitor data.

Expected behavior
The in-flight message immediately retransmit when mqtt client reconnected.

Environment

  • OS: Linux
  • Version: Using labrary of eclipse-paho-mqtt-c::paho-mqtt3as