My browser succeeds in opening my index.html which is on SD. It contains a leaflet implemented map composed of multiple tile images which are loaded from SD/atlases. Many of the tiles on the page load fine but some are missing. Terminal contains multiple copies (10-20) of the following:
E (25572) vfs_fat: open: no free file descriptors
[E][vfs_api.cpp:243] VFSFileImpl(): fopen(/sd/atlases/4uMaps/13/1303/2931.png) failed
The failed loads are for files that are present on SD and it is not always the same tiles that fail.
So,… obviously, I am out of file descriptors. How can I increase the FD limit? or alternatively, how can I delay or re-request the re-loading of tiles that fail?
Your book is a great resource! Thanks
Frank Evans
Hi Frank.
I think that error happens because you try to load too many files at the same time.
How are you serving your files? can you show me the snippet of code that does that?
Regards,
Sara
Sara, Thanks for your quick response.
My setup code for the server is:
initWiFi();
server.on(“/”, HTTP_GET, [](AsyncWebServerRequest *request)
{
request->send(SD, “/index.html”, “text/html”);
} );
server.serveStatic(“/”, SD, “/”);
// Start server
server.begin();
This works fine to serve the map tiles from local SD card.
The html code is:
<!DOCTYPE html>
<html>
<head>
<title>Leaflet offline map</title>
<link rel=”stylesheet” charset=”utf-8″ href=”css/leaflet.css” />
<link rel=”stylesheet” charset=”utf-8″ href=”css/style.css” />
<!– Make sure you put this AFTER Leaflet’s CSS –>
<script type=”text/javascript” charset=”utf-8″ src=”leaflet-src.js”></script>
<script type=”text/javascript” charset=”utf-8″ src=”leaflet.js”></script>
</head>
<body>
<div id=”map” class=”map”></div>
<script>
var mymap = L.map(‘map’).setView([45.4787,-122.6471],13);
L.tileLayer(‘atlases/4uMaps/{z}/{x}/{y}.png’,
{ maxZoom: 14 }).addTo(mymap);
L.marker([45.4787,-122.6471]).addTo(mymap)
.bindPopup(“<b>Hello world!</b><br />I am a popup.”).openPopup();
var popup = L.popup();
</script>
</body>
</html>
Again, this seems to work fine but the leaflet code is asking to open more files than the server can handle. The code survives and continues to run but there are missing tiles in the map background. I believe that I have no control over the leaflet async file load behavior. I need either an increase in the available open file count, or I need to trap the errors in the file system allowing me to re-request the loading of missing tiles. Do you have any other suggestions? Thanks…
Maybe you can send one image at a time? How many images do you need to send?
Instead of serving the images like this:
server.serveStatic(“/”, SD, “/”);
You would have a request for each image.
However, depending on the number of images, it might not be a good alternative.
Regards,
Sara
Sara, Thanks Again for your attention. The one image at a time might be ta solution but this itteration is done within the leaflet map JS code and I do not want to go there.
I discovered that the SD.begin() call has a default parameter for maxFiles = 5 so I CAN change the number. I am using Chrome as the browser and it opens async requests up to 6 (other browsers differ). So, I did succeed with maxFiles = 10 and those errors disapeared. I still get errors for missing files but they are in fact missing (off the edge).
I have one remaining error that may be of interest to you as follows:
[E][vfs_api.cpp:64] open(): /sd/atlases/4uMaps/11/325/734.png.gz does not exist
[E][vfs_api.cpp:64] open(): /sd/atlases/4uMaps/11/325/734.png/index.htm does not exist
[E][vfs_api.cpp:64] open(): /sd/atlases/4uMaps/11/325/734.png/index.htm.gz does not exist
E (276009) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (276009) task_wdt: – async_tcp (CPU 0/1)
E (276009) task_wdt: Tasks currently running:
E (276009) task_wdt: CPU 0: IDLE0
E (276009) task_wdt: CPU 1: loopTask
E (276009) task_wdt: Aborting.
abort() was called at PC 0x400fa30c on core 0
ELF file SHA256: 0000000000000000
…..
For context, this listing starts with the missing file error which is expected behavior. This file error does not always generate the timeout from the AsyncFTP. Sometimes the watchdog fires and that re-boots the CPU which IS an issue. If you have any information as to why the AsyncFTP might hang its CPU I would greatly appreciate that info.
I hope that my trouble/solution with the number of files will be useful to you and your fans.
Hi.
Thanks for sharing that. I didn’t know about the maximum number of files.
As for the other issue, I found the following discussions that might help with some tips:
- https://github.com/me-no-dev/ESPAsyncWebServer/issues/686
- https://github.com/me-no-dev/ESPAsyncWebServer/issues/772
Regards,
Sara