Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Is it possible to use AsyncWebServer.h instead of WebServer.h? #29

Closed
cancodr opened this issue Aug 20, 2020 · 5 comments
Closed

Is it possible to use AsyncWebServer.h instead of WebServer.h? #29

cancodr opened this issue Aug 20, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@cancodr
Copy link

cancodr commented Aug 20, 2020

I'm developing an ESP32 project which uses AsyncWebServer.h (https://github.com/me-no-dev/ESPAsyncWebServer). I realize that this library uses WebServer.h, however the two libraries seem to conflict with each other. Moreover, I think it will be more efficient to just use one.

Any hints on how to port this for use with AsyncWebServer, or at least how to get around the conflict issue in the short term?

@khoih-prog khoih-prog added enhancement New feature or request help wanted Extra attention is needed labels Aug 20, 2020
@khoih-prog
Copy link
Owner

Hi @cancodr

Thanks for using the library.

I'll definitely have a look at the possibility of supporting or make a new ESPAsync_WiFiManager lib to support ESPAsyncWebServer.

Currently, as the ESP_WiFiManager usage is short, and necessary only when Config Portal is required, I suggest you can try the following workaround (I personally haven't tried and seen the real issues and if it's working)

  1. Use local ESP_WiFiManager instance, created only when necessary e.g. to open Config Portal, either local or by using new and delete. See ConfigOnSwitch example and several other ones.
  2. Rename the ESPAsyncWebServer library's file names and/or classes, if and only if conflict happens.
  3. It's much better if you add namespaces to those ESPAsyncWebServer / WebServer libraries to avoid conflict.

Please post the results or arising issues to save us time, preferably with code we can verify / duplicate.

Regards,

@khoih-prog
Copy link
Owner

Hi @cancodr

Already successful to port this ESP_WiFiManager to use ESPAsyncWebServer instead of ESP8266WebServer/WebServer.

Will publish the new library as ESPAsync_WiFiManager within several days.

Regards,

@cancodr
Copy link
Author

cancodr commented Aug 21, 2020

That's great! Thank you!

@khoih-prog
Copy link
Owner

Release v1.0.11 is ready

ESPAsync_WiFiManager

Your enhancement request leading to this completely new library is noted in contributions-and-thanks ;-)


Why do we need this Async ESPAsync_WiFiManager library

  • Using asynchronous network means that you can handle more than one connection at the same time
  • You are called once the request is ready and parsed
  • When you send the response, you are immediately ready to handle other connections while the server is taking care of sending the response in the background
  • Speed is OMG
  • Easy to use API, HTTP Basic and Digest MD5 Authentication (default), ChunkedResponse
  • Easily extendible to handle any type of content
  • Supports Continue 100
  • Async WebSocket plugin offering different locations without extra servers or ports
  • Async EventSource (Server-Sent Events) plugin to send events to the browser
  • URL Rewrite plugin for conditional and permanent url rewrites
  • ServeStatic plugin that supports cache, Last-Modified, default index and more
  • Simple template processing engine to handle templates

Releases 1.0.11

  1. Initial coding to use ESPAsyncWebServer instead of (ESP8266)WebServer.
  2. Bump up to v1.0.11 to sync with ESP_WiFiManager v1.0.11.

@khoih-prog khoih-prog removed the help wanted Extra attention is needed label Aug 21, 2020
@Proggopogo
Copy link

I personally wouldn't suggest using the Asyncwebserver library for a project. It runs incredibly unstable and contains a few bugs that often cause the ESP-32 to crash. The WiFi Manager library is very useful, but there are quicker ways to enable a dynamic change between station and access point mode. I personally use LitteFS to access the file storage of my ESP-32, create a json document that I call config, and have a web portal where you can insert the username and password an send it via Post to the ESP.

To avoid useless crashes with the Asyncwebserver library, I'd suggest using the Mongoose webserver instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants