Problem using Husarnet in ESP32-Cam with Platformio

I’m trying to use husarnet for my AI Thinker ESP32-Cam project in VSCode using platformio. I tried to follow this example:

But, it always gave these error:
c:\users\xxx\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\xtensa-esp32-elf\esp32-psram\no-rtti\bits\gthr-default.h:781:12: error: ‘pthread_mutex_timedlock’ was not declared in this scope
Cannot find “C:\Users\xxx\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\nimble”.
Cannot find “C:\Users\xxx\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\husarnet”.

I also try to manually use Arduino IDE but i got either library error such as:
cannot found lwip_connect_r (and anything in lwip with _r)
or error with the compiler

I want to use ESP32-cam to stream image (video), but can also be accessed using different wifi without using another device (like raspy) beside esp32-cam. And after some search i found that it is possible using husarnet, but because i’m still learning in this programming topic so i can only rely to the example first.

Any help will be very much appreciated, Thanks!


I am also experiencing the same, using the Firebeetle ESP32-E. Interestingly enough - I tested the functionality on the same board on 27 March 2022, and it all worked perfectly. Now I’m experiencing the exact same issue - you described.

What I have found is that when I comment out the platform_packages (see below) in the platformio.ini file - the pthread_mutex_timedlock error goes away - only to end up with one error > src/main.cpp:3:10: fatal error: Husarnet.h: No such file or directory


platform_packages = framework-arduinoespressif32 @

To test - I’m using the below example:

Can the tech team from Husarnet please advise?

1 Like

Just to add to my update - I also tried the suggestion in, but didn’t solve the problem.

Just a gut feeling, after doing some more investigation - I think that the issue came in when the toolchain xtensa version was upgraded. When I started off with VS Platormio on 27 March 2022, the toolchain xtensa version was 2.50200.9 and the Husarnet functionality with the ESP32 worked.

I see that the toolchain xtensa was upgraded to 8.4.0+2021r2-patch3 on 26 April 2022.

Could this be the reason for the below errors?

c:\users\xxx.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\xtensa-esp32-elf\esp32-psram\no-rtti\bits\gthr-default.h:781:12: error: ‘pthread_mutex_timedlock’ was not declared in this scope?

Just to add, I am experiencing the same problem with husarnet and nimble errors quoted above with the simple basic example at the bottom of on the ESP32 tab.

If any have solved the error I’d appreciate if you can drop a hint.