256dpi / arduino-mqtt

MQTT library for Arduino
MIT License
1.01k stars 232 forks source link

Publishing Data from Task on the ESP32 FreeRTOS #254

Closed aseitasi15 closed 1 year ago

aseitasi15 commented 3 years ago

I am using MQTT broker version 3.11 on AWS IOT.

There is no problem publishing data in ESP32. However, if I do the same part in the task of FreeRTOS, the data will not be published. Are there any hints to resolve this issue?

Here is the simple test code I tested.

static void task(void *pvParam) { while(1){ bool result = client.publish("topic_pub", "data here"); Serial.println(result); vTaskDelay(100); } }

256dpi commented 1 year ago

The library is not thread-safe, you need to ensure that only one thread is using the client. Otherwise, publishing form another thread should work.

Closing as stale, please reopen if issue persists.