Running MQTT Demo periodically with OTA Update Demo causes firmware to restart

I suppose re-creating a MQTT task might make sense when the communication is less frequent;

A task which is not in “Ready” state, does not consume any CPU. So I do not think re-creating provides any benefit even in less frequent communication scenario. You should rather put the task to sleep using vTaskDelay or vTaskDelayUntil.

The difference being, the MQTT connection is being established when running the OTA Update demo after creating the OTA Update thread. The created MQTT connection is then saved as sharedMqttConnection, which is then used by the MQTT demo, over a second thread.

That should work too as long as you ensure that the MQTT task does not access sharedMqttConnection until the OTA task has created it.

Thanks.