New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uploading multiple files raises HEAP and AsyncTCP errors #1381
Comments
Maybe it's a watchdog time-out because server->on(...) wants a fast return. Make a separate thread to upload files, and trigger it from handleFiles::handleUpload, passing the parameters. For example, put request data in a struct and pass it (as reference) to a Ticker (separate library) callback. |
Hi, |
Hi Tobias, I agree it shows a heap error and I'm not sure it's a watchdog timer issue. I only know there are limits on how much can be done in a call back. I make the suggestion because it solved a similar problem for my application. And it gives flexibility to process the uploads individually to reduce heap usage. Maybe also take a look at chunked response in the readme. This great library has not been updated in a long time so you may have to find your own work around. |
solved my myself ;) i opened permanently That shows the problem, this call allocates memory without give free if it not used final solution function: void handleFiles::handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { String logmessage = "Client:" + request->client()->remoteIP().toString() + " " + request->url(); Serial.println(logmessage); if (!index) { // open the file on first call and store the file handle in the request object request->_tempFile = LittleFS.open("/" + filename, "w"); Serial.printf("Upload Start: %s\n", filename.c_str()); } if (len) { // stream the incoming chunk to the opened file request->_tempFile.write(data, len); rtc_wdt_feed(); Serial.printf("Writing file: %s ,index=%d len=%d bytes\n", filename.c_str(), index, len); } if (final) { AsyncResponseStream *response = request->beginResponseStream("text/json"); response->addHeader("Server","ESP Async Web Server"); // close the file handle as the upload is now done request->_tempFile.close(); Serial.printf("Upload Complete: %s ,size: %d Bytes\n", filename.c_str(), (index + len)); } } |
Hi,
I'm using a simple fileupload to littleFS partition.
With only one file it works perfectly, but if i want to upload multiple files by selectiong a directory, the esp crashes after uploadfing 1-2 files
@me-no-dev do you have any suggestions?
The text was updated successfully, but these errors were encountered: