Can two different server functionalities operate simultaneously within a single ESP32 program? Specifically, can both ESPAsyncWebServer and ESP32

I am currently working with the ESP32 module and have created a web interface to display sensor values by using the ESPAsyncWebServer.h library along with the AsyncWebServer server(80). Now, I want to incorporate a camera into my project, but this requires me to use the ESP32WebServer.h library and create another server called server2(80).

How can I effectively integrate these two servers into the same program? When I attempted to do so, the script compiled successfully, but only one of the servers - whether it be begin.server() or begin.server2() - would function properly while the other did not.

I also experimented with combinations like server.end() and server2.begin() to switch between servers, but encountered issues as the ESP32WebServer.h library does not support server2.end().

Thank you for your assistance, and please excuse any language errors in my communication.

Answer №1

Running both servers on the same port (80 in this case) is not possible.

Each software on a device is uniquely identified by the port number that handles the data for that connection, therefore having two different servers on the same port is not feasible.

The camera web server software likely has streaming video on port 80 embedded within it, so running it on a different port may cause certain parts to malfunction.

To resolve this issue, create the two servers on separate ports:

ESP32WebServer server(80);   // camera software
AsyncWebServer server2(81);  // everything else

You can then access the async web server through links like:

http://esp-ip-address:81/path

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

State management through Functional Reactive Programming

Many believe that FRP involves managing event streams without the need to explicitly handle state. An example of this can be found here: Others argue in favor of FRP by highlighting the challenges associated with programming solely through side-effects, a ...

Include a class on the final row when looping through the stripes in a responsive manner

In each row, I have a column with a blue strip that is generated using jQuery based on the number of rows. My question is how to add a class to the last strip if the row only has 1 or 2 boxes: If the last row has 1 box, add class='last' to the ...

What does the `Class<Component>` represent in JavaScript?

Apologies for the lackluster title (I struggled to think of a better one). I'm currently analyzing some Vue code, and I stumbled upon this: export function initMixin (Vue: Class<Component>) { // ... } What exactly does Class<Component> ...

Tips for accessing the 'styled' function in Material UI ReactHow to utilize the 'styled' function

Hey there, I'm facing an issue while trying to export a styled AppBar. Check out my code below: import * as React from 'react'; import { styled, useTheme } from '@mui/material/styles'; import MuiAppBar from '@mui/material/AppB ...

What is the best way to ensure that a link fragment scrolls to the top of the page in Angular?

Having trouble with link fragments in my Angular single-page-app: <a href="/#/search">Search</a> When clicking this link, it takes me to the right page but keeps my scroll position. I want it to scroll to the top of the page so I'm curre ...

Tips for effectively managing loading and partial states during the execution of a GraphQL query with ApolloClient

I am currently developing a backend application that collects data from GraphQL endpoints using ApolloClient: const client = new ApolloClient({ uri: uri, link: new HttpLink({ uri: uri, fetch }), cache: new InMemoryCache({ addTypename: f ...

Getting a specific piece of information from a JSON file

I am encountering an issue with my JSON file collection. When I access it through http://localhost:5000/product/, I can see the contents without any problem. However, when I try to retrieve a specific product using a link like http://localhost:5000/product ...

What is the clarification on AngularJs' ng-options?

In my demo, I have a small setup. Essentially, it consists of a select element with the following data: address: { select: { code: "0", name: "Select proof of address" }, letter: { ...

Restricting variable values in Node.js

As I work in an IDE, there is a feature that helps me with autocomplete when typing code. For example, if I type: x = 5 s = typeof(x) if (s === ) //Cursor selection after === (before i finished the statement) The IDE provides me with a list of possible ...

Error 500 occurs when attempting a remote call to the internal server while exploring the Agile Web Development with Rails 4 book in Chapter

Currently in my 5th week of learning rails, I have been following the book "agile web dev with rails 4". After completing chapter 11, I decided to implement a remote call to remove all quantities of an item from the cart. However, I encountered an internal ...

Steps to retrieve the central coordinates of the displayed region on Google Maps with the Google Maps JavaScript API v3

Is there a way to retrieve the coordinates for the center of the current area being viewed on Google Maps using JavaScript and the Google Maps JavaScript API v3? Any help would be greatly appreciated. Thank you! ...

Navigating a JSON response using jQuery

I've got the ability to send data to the server using JSON and receive the appropriate response, but I'm currently struggling with displaying the returned JSON data in an alert. Despite receiving an alert, it only shows "undefined" as the text va ...

Should I convert to an image or utilize the canvas?

I'm debating whether it's more efficient to convert a canvas drawing into an image before inserting it into the DOM, or if it's better to simply add the canvas itself. My method involves utilizing canvas to generate the image. ...

What is preventing the use of data post submission in React JS?

After posting data to the navigation, I retrieve it and then use the following code: .then(data => console.log(data.PathPDF)) .then(data => window.open(data.PathPDF, '_blank', 'noopener,noreferrer')); While I can successfully ret ...

Invoking a function from a Python script

Python is a new territory for me and I find myself slightly confused. My aim is to extract data from an education API using a python script, but I'm not quite sure how to go about it. Below is the Python script in question: #!/usr/bin/python # Impor ...

Creating an HTML webpage that contains scripts for handling responses in Node.js

I am a beginner in node.js and I'm attempting to display an html file named index.html which includes a reference to a javascript file called test.js: <!-- Content of index.html --> <html> <head> <script src="test.js">&l ...

Encountering Vue linting errors related to the defineEmits function

I am encountering an issue with the linting of my Vue SPA. I am using the defineEmits function from the script setup syntactic sugar (https://v3.vuejs.org/api/sfc-script-setup.html). The error messages are perplexing, and I am seeking assistance on how to ...

What is the best way to conceal content within a URL while still transmitting it to the server using node.js and express?

I have been trying to figure out how to hide certain content from the URL, but still need to send that information to the server in my Express app. So far, I haven't found any solutions that work. For example, if I have a URL like www.abc.com/viewblo ...

Creating a dynamic className string in JavaScript with React

In my current project, I'm implementing mobile support by creating separate styles for desktop and mobile. Although most components are the same on both platforms, I have two .scss files dedicated to each. To apply the correct styles, I use a combina ...

Assemblage of Marionettes: Adding multiple elements to the DOM

I am working on a Marionette application and have come across an issue with inserting new tab items. I have a collection of tabs, but when adding a new item, I need to insert DOM elements in two different areas. The problem is that Marionette.CollectionV ...