We are using the Azure IoT SDK C source code package in our embedded/firmware project. We might have come into a situation where some devices have spotty communication with the cloud and outgoing messages (Device to cloud) are getting stuck and accumulated to the point the device runs out of memory. We do get a connectivity error at some point but in certain scenarios, it might not be fast enough and a lot of outgoing messages could be queued up right before it.
We are connecting to the IotHub through MQTT.
I saw in the code there is a "Message Timeout" client option that can be enabled. However, there is a clear Deprecation notice right above it.
Keeping in mind we are using MQTT, what other option is there to ensure we don't encounter a situation where outgoing messages would pile-up in an outgoing queue without timing out already queued-in messages?
Thank you.
To prevent outgoing messages from piling up in the outgoing queue without timing out Here's a general approach you can take:
Send an outgoing message, timestamp it with the current time, and increase the timestamp.
code taken from the reference github