ESP32S multiple http servers

Cool Javelin
Posts: 12
Joined: Wed Oct 20, 2021 3:58 am

ESP32S multiple http servers

Postby Cool Javelin » Wed Oct 20, 2021 5:10 am

Hello, I am developing an app that serves up an interactive web page that is, of course, on port 80.

I want to add the WebSerial to my code so I can do better of keeping track if my updates (here is where I learned about that, https://randomnerdtutorials.com/esp32-w ... l-library/)

Am I correct in assuming that starting 2 servers from 2 libraries will use twice the code space?

I'd like to combine the following into a single server, but I am not sure how to go about doing that, Please help.

My code for the OTA begins thus... (note the server starts on port 80)

Code: Select all

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <Update.h>

WebServer web_server(80);
  <some other server startup stuff>
  
(in setup)
	web_server.begin();
	
(in loop)
	web_server.handleClient();
To start the serial server...(note I made the server start on port 81)

Code: Select all

#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <WebSerial.h>
AsyncWebServer serial_server(81);

(in setup)
  WebSerial.begin(&serial_server);
  WebSerial.msgCallback(recvMsg);
  serial_server.begin();

(in loop)
 <nothing>

Currently, this does not work, but I do not think it is related to having 2 servers, but I am not sure.

I am barely on the edge of understanding how these libraries work, I don't have a lot of experience with them yet, so please use small words and go slow.

Thanks, Mark.

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 76 guests