IotNetworkAfr_Close and IotNetworkAfr_Destroy

Hi all

iot_network_freertos.c FreeRTOS Platform V1.1.2

I’m calling IotMqtt_Connect() (which connects) and then IotMqtt_Disconnect() (which hangs). I traced this to IotNetworkAfr_Close and IotNetworkAfr_Destroy, both of which call xEventGroupWaitBits on _FLAG_RECEIVE_TASK_EXITED with xClearOnExit set to pdTRUE.

As I understand it, the second call (from …Destroy) waits forever, because the previous call (from …Close) cleared the flag. Can this be the case?

Alternatively, I need to be doing something, maybe in the MQTT onDisconnect callback? But I havn’t been able to find much inspiration in the examples provided.

Bottom line, what am I doing wrong? Or what is MQTT doing wrong?

Good catch. This is a known issue that was fixed recently. I’d recommend applying the latest changes to iot_network_freertos.c in master: amazon-freertos/iot_network_freertos.c at master · aws/amazon-freertos · GitHub

Hi Oscar

Thanks. I have pulled the latest sources (the update came in after I pulled the latest sources and while I was busy porting).

I’m wondering whether this has been tested with configASSERT turned on. Because I’m still getting a failure on line 703

configASSERT( ( connectionFlags & _FLAG_RECEIVE_TASK_EXITED ) == _FLAG_RECEIVE_TASK_EXITED );

for the same reason – IotNetworkAfr_Close waited for _FLAG_RECEIVE_TASK_EXITED with xClearOnExit == TRUE, so _FLAG_RECEIVE_TASK_EXITED is no longer set.

Thanks

W

Hi W,

Thanks for pointing it out, and sorry for the delayed response. We actually fixed this back in March 31st:

Please feel free to reach out once again if you are still facing issues.

Best regards,
Oscar