eclipse / paho.mqtt.embedded-c

Paho MQTT C client library for embedded systems. Paho is an Eclipse IoT project (https://iot.eclipse.org/)

Home Page:https://eclipse.org/paho

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use cycle, loop, Run properly?

MikhailNatalenko opened this issue · comments

Hi! I face timeouts problems with a receiving of an enormous amount of data. My test is very primitive: I constantly send qos0, qos1, qos2 messages to my device (no delays, high load), I don't use Yield, just MQTTStartTask.
Sometimes, when I get qos2 messages, I don't have enough time to handle it properly (there is a hardcoded value 500 for a cycle), so I catch timeout, that cleans session (all subscription erase)

I think it's a pretty common scenario for qos2 messages. Sometimes they can handle for a really long time (about 1 second). So, what should I do?

The Yield works even worse because it runs the cycle with elapsed value. There could be a case, when Yield starts the cycle with a 10ms timeout and it can't finish QOS2 as well.

Increasing the Timeout in MQTTRun works like a charm.

I understand that the problem is the synchronous logic of qos2 handling. And it would be pretty hard to make it asynchronous, to avoid timeout issues.