Chat freely about anything...

User avatar
By JacTaiwan
#91181 Question: Is there an "EASY" way to increase the Max number of allowed "OPEN' files ( =====>SPIFFS)

I use #include "ESPAsyncWebServer.h" on a esp8266 HTML page with roughly 100 images with in total only 7 unique xxxx.gif names
( see the web index pages as a digital VU meter )

It seems that sometimes the async load of SPIFFS increases during an index.html load to more than 6 different images
simultaniously are being downloaded .....( this is one of the 7 different gif images )
ps: if (!MaxOpenFiles is only for testing the error by using a different file
********************Part
server.on("/img/Icon-blink-red.gif", HTTP_GET,handle_blink_red_gif);
~~~~
void handle_QBoxIcon_red_gif(AsyncWebServerRequest*request) {if (!MaxOpenFiles("/Icon-red.gif")){request->send(SPIFFS, "/Icon-red.gif" ,"image/gif" );}}
~~~~~~
boolean MaxOpenFiles(String CFileName){
//SPIFFS.gc();
//CFileName = "/QBox_Debug.txt";
DEBUG_MSG("Trying to perform: server(on)(" + CFileName);
File fsFile;
fsFile = SPIFFS.open("/QBox_Debug.txt", FILE_READ);
if (!fsFile) {
DEBUG_MSG( " file_reading of dummy read /Debug.txt failed. We need to ignore the actual file request of: " + CFileName);
return true;}
else {
fsFile.close();
return false;}
}
***********************
At that moment a file can't de opened
I have "a strong feeling" that this is due to a forced limit of max open files and has nothing to do with
memory stack etc

I UNDERSTAND THAT THE MAX NUMBER OF OPEN FILES IN SPIFFS IS HARD-CODED TO "5"

This parts gives the problem as too many files are opened during the index.html
server.on("/", HTTP_ANY,handle_OnConnect);
**************
void handle_OnConnect(AsyncWebServerRequest *request) {
request->send(SPIFFS, "/index.html" , String(), false, processor);
}