How to send HTML page from a Web Server asynchronously in ESP-IDF?
is it possible to send the HTML page from a Web Server in async mode upon initial client request?
tried that and all i get in the browser is the raw HTML script
maybe I am using the wrong function :
Solution:Jump to solution
In the ESP-IDF's HTTP server component, the
httpd_start()
function sets up both a listening TCP
socket for handling HTTP
traffic and a control UDP
socket for internal control signals. However, for serving HTTP
responses, including HTML
pages, you typically interact with the HTTP
request and response structure provided by the server rather than directly managing sockets @te09 Replies
Hi @te0 To serve an HTML page from an
ESP32
web server, you should use a standard HTTP
response instead of a WebSocket
function. The httpd_ws_send_data_async
function you mentioned is designed for WebSocket data, not for serving web pages.To be able to send HTML page upon request you should first create a http handler
And then setup the sever to call on the handler upon user request
Yeap, and the catch is that the HTML page is 4000 bytes long:facepalm:
I will try to send it in chunks
I thought about sending back the page with a socket because in the documentation it says :
httpd_start(): Creates an instance of HTTP server [...]. The server has both, a listening socket (TCP) for HTTP traffic, and a control socket (UDP) for control signals, which are selected in a round robin fashion in the server task loop
You can use the
httpd_resp_send_chunk
function for thisSolution
In the ESP-IDF's HTTP server component, the
httpd_start()
function sets up both a listening TCP
socket for handling HTTP
traffic and a control UDP
socket for internal control signals. However, for serving HTTP
responses, including HTML
pages, you typically interact with the HTTP
request and response structure provided by the server rather than directly managing sockets @te0Thanks, it works now, I splitted it up in 2 pieces