WebServer vs ESPAsyncWebServer

Hello Arduino geniuses:

I am building an ESP32 project with multiple web functions, and the online tutorials refer to these 2 different libraries.

Here is an example of what I am trying...

#include <WebServer.h>
WebServer update_server(82);

#include <ESPAsyncWebServer.h>
AsyncWebServer async_server(80);

In both cases, the tutorial called the instantiated thing "server" and I think I was smart enough to rename them.

Questions:

  1. Are these libraries incompatible with each other in the same program/sketch?

  2. Are they just 2 implementations of the same thing written by 2 different authors?

I have come to understand that because of the open source nature of Arduino, there are many people writing libraries to do the same thing.

  1. Is there a central location or forum thread(s) that may help understanding incompatible/conflicting libraries?

Ultimately, my requirement is to have a web form to fill and process.

Thanks, Mark.

They both provide functionality as a web server. You will need to pick one and use it. The Async version does more stuff in the background.

First, Arduino.cc has nothing to do with ESP32 "Arduino" as the core was written by Espressif; docs can be found here:
https://docs.espressif.com/projects/arduino-esp32/en/latest/

Espressif writes their professional libraries as ESP-IDF which is discussed:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/

To get "Arduino compatibility", Espressif writes wrapper-code around the IDF and injects some custom code. When libraries are written, they can reference IDF calls directly (good) or they can reference "Arduino wrapper" code (not so good.)

Espressif is not alone, STM does exactly the same and I suspect many other microcontroller vendors too. So, things are not always cut-n-dry. You must take time and do appropriate research to understand what is really happening.

I can't think of a single reason to NOT use the AsyncWebServer. It provides MUCH more functionality, and is VERY easy to work with.

I think I do understand the concept of what you are saying, although it took a while to actually figure out the big picture. Many tutorials jump right into the nitty gritty without explaining the overall picture. Thank you for those links, I will go read more.

However, as for the "WebServer.h" and the "<ESPAsyncWebServer.h>", only one has ESP in the name yet either can be used. From what I can tell, simple naming conventions are not really reliable to differentiate the libs.

It's not that I want a recommendation as to which library to use, I want to know if they can both be used in the same sketch at the same time? Do they both offer the same capability?

There are many choices of libraries to do things for a task, clearly, some are better then others, but that is for another topic.

I am asking "How do I know when 2 libraries will cause conflicts with each other?"
Is there a website/forum that helps keep track of that kind of thing?

Thanks, Mark.

Given what folks here have said, why would you want to do that?

Even if you could run them both, what possible REASON would there be to run two webservers concurrently on the same processor? It makes no sense, and would be a massive waste of memory and processor power.

Unfortunately, I know of no single resource that provides such a resource; goodness knows it would only be a snapshot! Everytime I open the ArduinoIDE the darn thing wants to update library(ies.) Mainly Adafruit is the reason that I no longer use
#include <libraryname.h>
and have embedded sketch libraries into sketch folders and now use
#include "./libraryname.h"

The ESP32 has a built in multi-tasking and multi-processing OS called freeRTOS. AsyncWebServer is written to use freeRTOS.

I'd like to thank everyone that has replied here trying to help me. I really appreciate the time you are putting into this.

I really don't want to use 2 different but similar libraries, it's just that the examples I have found do so.

I want 4 major things going on in this machine, listed by priority then are:

  1. A web server with forms input to get up to 140 input fields with one submit button (AsyncTCP.h and ESPAsyncWebServer.h or WebServer.h). Not working.

  2. OTA because this will eventually be hidden in a cubby somewhere (WebServer.h and Update.h). Works OK.

  3. FTP server so I can store the http headers and beautify my pages at my leisure (ESP8266FtpServer.h). Works OK,

  4. Remote web diagnostics as there won't be a serial monitor in the final setup (WebSerial.h). Not working.

The web page on the default port 80 tutorials want me to use the AsyncTCP.h and ESPAsyncWebServer.h. (I haven't gotten this to work properly yet, but I think that is for another topic.)

I can find no good examples to do a form input using WebServer.h, and I haven't found any examples that show OTA using ESPAsyncWebServer.h.

I tried to simply remove the WebServer.h and modify the OTA code, but I couldn't get that to work.

Also, even though this is an ESP32, I have included "ESP8266FtpServer.h." I haven't found a ESP32FtpServer but what I have is working.

Mark.

Hi cooljavelin,

Wow your points 1 to 4 are quite a lot of stuff.
I haven't done something with a similar complexity myself yet.

I'm using ElegantOTA, ESP-DASH and Webserial.
The ElegantOTA functionality is
you have a webinterface with a standard-dialog "choose file from drive"
which will be a pre-compiled binary as a new firmware or to choose "files"
and click on "upload"

I haven't used the upload file-option yet.

ESP-DASH hides away all html-coding in the backround
it uses a javascipt framework called "Vue" The "price" is a non-changeable design of the inputfields

The advantage is that the interaction between your arduino-code and the website-code is simplyfied to

Card MyParameter1Card(&MyDashboard, TEXT_INPUT_CARD, "Parameter 1");

  MyParameter1Card.attachCallback([&](String MyTextInput) {
    MyTextInput += "Hello world";
    // additiona code to be executed if you click on the webinterface-button
    ServoMinPulseCard.update(MyTextInput); //Make sure we update our value and send update to dashboard */
    MyDashboard.sendUpdates();
    Serial.print( F("Button Triggered: ") );
    Serial.println(MyTextInput );
  });

I haven't tested it with 140 textinputcards if so many inputfields cause memory-problems

and the same author offers "Webserial" which is a what the name says
a web-interface based serial monitor

depending on the comfort you want to have to see all these parameters it might be sufficient to use webserial and to send / receive commands that transfer your parameters. You have to store the parameters inside the devices memory anyway.

not sure if the textinputcard is only included in the pro-version

best regards Stefan