coreMQTT agent timeout in transport recv

Hello,

We want to use the MQTT for firmware update and to do so we are transmitting .bin file from application software → Broker → MCU. During the transfer, we are getting the following error while receiving the file via MQTT.

[MQTT Agent] Unable to receive packet: Timed out in transport recv. 2713 377575 993609
[MQTT Agent] Packet reception failed. ReceivedBytes=11824, ExpectedBytes=578807.

Are we doing right? can we send big file via MQTT? if yes, what configuration needs to be verified?

It looks like the timeout occurs here: https://github.com/FreeRTOS/coreMQTT/blob/v1.1.2/source/core_mqtt.c#L780. That will happen if MQTT_RECV_POLLING_TIMEOUT_MS milliseconds passes between calling the containing function or last receiving data (the timeout is reset when data is received here: https://github.com/FreeRTOS/coreMQTT/blob/v1.1.2/source/core_mqtt.c#L755).

Have you tried increasing the value of MQTT_RECV_POLLING_TIMEOUT_MS? https://freertos.org/Documentation/api-ref/coreMQTT/docs/doxygen/output/html/core_mqtt_config.html

Also, is the value 578807 correct? Do you have a buffer large enough to store the received bytes? Is 11824 the size of the actual buffer? How many bytes are you attempting to receive?

Additionally this will probably also help: https://www.freertos.org/Documentation/api-ref/coreMQTT/docs/doxygen/output/html/mqtt_timeouts.html

Thank you Richard,

I have increased the MQTT_RECV_POLLING_TIMEOUT_MS from 1000mS to 10000mS. The keep-alive is set to 15Secs. still seeing the same issue.

Yes, 578807 is the correct value. That’s the bytes I am trying to receive. which buffer you are talking about? we set the MQTT_AGENT_NETWORK_BUFFER_SIZE to 2MB ( 0x200000 )

Here are the complete logs

[MQTT Agent] Unable to receive packet: Timed out in transport recv.
[MQTT Agent] Packet reception failed. ReceivedBytes=1456, ExpectedBytes=578807.
[MQTT Agent] Exiting process loop due to failure: ErrorStatus=MQTTRecvFailed
[MQTT Agent] MQTT operation failed with status MQTTRecvFailed
[MQTT Agent] MQTT agent command loop exited(status = 4)
[MQTT Agent] MQTT connection disconnected due to an error
[MQTT Agent] Disconnecting TCP connection.
[IP-task] Socket 29341 -> 127.255.255.255:1883 State eESTABLISHED->eFIN_WAIT_1
[MQTT] Notify->DISCONNECTED_BAD_PACKET
[MQTT] Broker disconnected

Which MQTT broker are you using? If AWS IoT Core then as per the “message size” on this page it looks like 128K is the limit.

It would be good to put a time stamp into the logs and show the log from before the attempted receive so we could see if the timeout was as expected. The time stamp could be the tick count if we know the tick frequency, or the ms time otherwise.

It looks like you successfully received one full frame, but no more. Can you please post (preferably attach) the implementation of your transport interface.

Looks like your buffer size is fine.

Hi Richard,

Finally figured out the issue after checking the TCP packets. There were multiple frame errors and mainly due to USB-Ethernet hub speed. Tested on other system without it and worked perfectly fine.

Thank you

Thanks for taking the time to report back.