boblemaire / asyncHTTPrequest

asynchronous HTTP for ESP using ESPasyncTCP. Works like XMLHTTPrequest in JS.
GNU General Public License v3.0
64 stars 31 forks source link

Compilation error on esp32 #36

Closed RomeHein closed 3 years ago

RomeHein commented 3 years ago

Hi, I have that compilation error when trying to integrate asyncHTTPRequest to my project for an esp32:

libraries/asyncHTTPrequest/asyncHTTPrequest.cpp.o:(.literal._ZN16asyncHTTPrequest8_connectEv+0x28): undefined reference to `AsyncClient::AsyncClient(tcp_pcb*, tcp_pcb*)'
libraries/asyncHTTPrequest/asyncHTTPrequest.cpp.o:(.literal._ZN16asyncHTTPrequest8_connectEv+0x2c): undefined reference to `AsyncClient::connect(char const*, unsigned short, bool)'
libraries/asyncHTTPrequest/asyncHTTPrequest.cpp.o: In function `asyncHTTPrequest::_connect()':
/Documents/Arduino/libraries/asyncHTTPrequest/src/asyncHTTPrequest.cpp:187: undefined reference to `AsyncClient::AsyncClient(tcp_pcb*, tcp_pcb*)'
/Documents/Arduino/libraries/asyncHTTPrequest/src/asyncHTTPrequest.cpp:187: undefined reference to `AsyncClient::connect(char const*, unsigned short, bool)'

I'm using the AsyncTCP library without any issue as the server running in my project is async. So I don't get why AsyncClient would be undefined. I'm using vscode as IDE. any help much appreciated :)

boblemaire commented 3 years ago

For ESP32 the code includes the ESP32 specific ESPAsyncTCP.h. Depending on your IDE, you need to include that in your compile.

I've moved away from this code for ESP32. It works OK but doesn't support https. There is a newer esp32HTTPrequest that is can be substituted. It uses all of the same methods and works the same way, except that it's not asynchronous. It uses the native ESP-IDF HTTP client, which seem to work well. The async capabilities of the older asyncHTTPrequest were needed to get async on the ESP8266, but with the ESP32, you can simply run it in a separate FREErtos task to avoid blocking. Next pass I intend to add some code to allow seamless async by forking a task to do the open and perform, so it will work just like the older asyncHTTPrequest, but also support https.

Caveat-emptor, the new module, while based on the older async code, is not fully tested. It serves my needs reliably but beyond that I'm open to looking at problems others may have, or better to entertain PRs to fix any new issues.

RomeHein commented 3 years ago

thanks for your very prompt answer. For the esp32 the AsyncClient would be in AsyncTCP.h library. Which I already include in my sketch:

#include <AsyncTCP.h>
#include <asyncHTTPrequest.h>

and I still get this compilation error.

I was using the native HTTPClient for the esp32 but I kept having this weird issue with it, where any request would send back a "connection refused", even with something as simple as this:

HTTPClient http;
http.begin(client, "http://192.168.1.110:80/test");

Also I'm trying to use as much async code as I can, as the firmware (ESPecial) I'm developing do many different things at the same time. Even with two cores it can get tricky. For instance I use a telegram bot (from this repo: https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot) which is not async, and therefor has to poll telegram server every second or so, then wait for an answer. This block one core on its own... And now I'm adding video streaming 😅

boblemaire commented 3 years ago

Closing as stale