vTaksDelay stops scheduler without resuming it after a few calls

In which case we will need a little more information. If you are sending publish messages I assume you have already connected to the MQTT broker. Did you use one of the examples provided in either of the FreeRTOS or AWS git repos as a starting point? Or maybe STM32Cube as the starting point? Is that where the implementation of prvMQTTPublish() comes from?