Hello, I've been working this for two weeks and researched so much that I need new glasses.
I have a 20MHz 1284 based Arduino with an ESP-01 module as a WiFi shield using the WiFiEsp library.
I want to be able to see the current status and log records as well as be able to configure the project via HTML.
The main web page contains, several iframes such as:
and also a <script src="confg.js""></script.js>
For now, each of those "src" is a separate file on the SD. Later, they will not be a file on the SD but will be generated dynamically, for instance to show the current status. (And will probably be sent using chunked encoding).
If I click on the main htm file on the SD from my laptop, everything loads as I expect. Even the script fires. The SD contains a favicon.ico and it also loads.
However, when using the Arduino as a server, the iframes do not load. Ever. The main page loads, the script loads (last src reference in the main html), but not the iframes.
Here is what I think I have learned. When using the ESP-01 as a shield, it only supports one socket for use as a server so there can only be one client at a time active. Parallel requests therefore cannot be supported.
Sending of a file takes a couple of seconds and maybe the Arduino isn't fast enough to process multiple requests one after the other.
Most example webserver sketches send one file and close the connection. The HTTP response states "Connection: close". Using this scheme, I truly seem to only receive the request for the main file and no others.
I have changed the Arduino server to use "Connection: Keep-Alive" and "Keep-Alive: max=6, timeout=60". While sending any given file, I also poll for client.available and can actually capture and respond to the request for the confg.js script. It fires on the webpage so I know that part is working. (Everything on the one client connection which is only closed after inactivity for two minutes.)
The main html takes about 3 seconds to send, the script only about 1.5 seconds (SD overhead included).
The problem is, nothing I do seems to cause the Arduino server to actually receive a request from the browser for any of the iframes!
What I don't know: Is my browser (mainly Microsoft EdgeVersion 87.0.664.75 but I have also tried others) attempting to load the iframes with parallel connections? How can the server prevent parallel connections and force everything onto the one persistent connection?
All responses from the server (main html, iframes and script) are in the form:
HTTP/1.1 200 OK\r\n
Content-Type: text/html\r\n
Content-Length: 3800\r\n
Connection: Keep-Alive\r\n
Keep-Alive: max=6, timeout=60\r\n
\r\n
(And yes, script is type: text/javascript)
Do I have to associate the individual iframe responses to the name requested? Would make sense to say, you ask for status.htm and here it is. On the other hand, the confg.js works fine and isn't named?
Do I have to put something in my response headers so the browser knows not to use parallel connections?
I swear, if I ever get this figured out, I'm going to write a 400 page tutorial and post it online somewhere. Grrr....
Thanks for any tips anyone may have!