espressif / esp-mqtt

ESP32 mqtt component
Apache License 2.0
610 stars 257 forks source link

Simultaneous MQTT and HTTP server (IDFGH-6565) #218

Closed SERIDJ closed 2 years ago

SERIDJ commented 2 years ago

hi,

iam usig esp32 and esp idf 4.3 Framework .

is it possible to run using 2 task an MQTT client (port 8883) to publish data and have web page at same time . for now each task work well separately. But i got error when i try to run both task at same code.

like :

E (385828) TRANS_TCP: tcp_poll_read select error 113, errno = Software caused connection abort, fd = 57 E (385848) MQTT_CLIENT: Poll read error: 119, aborting connection. W (385848) httpd: httpd_accept_conn: error in accept (128). E (395888) TRANS_TCP: [sock=54] connect() error: Host is unreachable E (395888) MQTT_CLIENT: Error transport connect

david-cermak commented 2 years ago

Hi @SERIDJ

It seems like you might be running out of available sockets in your system. Please check the settings of CONFIG_LWIP_MAX_SOCKETS

No problem in general to run multiple instances of mqtt client and http server at the same time. Things to consider: Enough socket descriptors, enough memory, each instance of the mqtt client should have a different client id.

SERIDJ commented 2 years ago

@david-cermak thanks for ur replay

yes i fixe it , its probleme of stack_size ... but how i can calcule the exact size for each task, i know its by word so esp32 is 32 bit so one word is 4 bytes ....

david-cermak commented 2 years ago

yes i fixe it , its probleme of stack_size

Ok, thanks for the update. Closing this.

how i can calcule the exact size

While It is theoretically possible to calculate the needed stack depth, I'd suggest trying this API to get the maximum runtime stack usage uxTaskGetStackHighWaterMark while running your app for some time.