eclipse / paho.mqtt.c

An Eclipse Paho C client library for MQTT for Windows, Linux and MacOS. API documentation: https://eclipse.github.io/paho.mqtt.c/
https://eclipse.org/paho
Other
1.95k stars 1.09k forks source link

QoS and retain both set to 1 then MQTT Client goes to MQTT Close session after time greater than keep alive interval and then reconnection #1477

Open sayali-gadre opened 4 months ago

sayali-gadre commented 4 months ago

I am using the MQTT Client library for publishing and subscribing messages to IoT Core service of the AWS Cloud.

When continuously publishing MQTT messages for a topic with QoS and retain flag set to 1, the messages stop publishing after client ID 17 (serially), then client goes to close session after almost twice of keepalive interval (till then task is suspended) and then to reconnection again. After reconnection, same process repeats 2-4 times and then, the task stops.

When seen in debug, time is stuck in PUBACK timer wait function which calls for reading the type of packet. The MQTT task in FreeRTOS gets blocked for that time interval.

Is there any minimum wait period required for PUBACK if publishing to the same topic continuously? If delay of 1s is given each time after publishing to the topic, then, it works properly without any issue. It is not the issue when retain flag is not set.

Could you please provide some insights into this? Thank you in advance.

icraggs commented 2 weeks ago

Sorry for long delay in response. The keepalive interval dictates how long the client will wait for some traffic to occur on a connection, so it is this which will govern how long it would wait for the PUBACK.

If by publishing continuously you mean as fast as you can, then maybe the receiving thread is being starved of CPU time? Anyway, there is a trace function in the Paho library (described in the README) which could shed more light if this is still a problem for you.

I thought that FreeRTOS now has its own MQTT client?