-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Readme update - file streaming #770
base: master
Are you sure you want to change the base?
Conversation
* "Respond with file content using a callback and extra headers" section * "Serving static files by custom handling" section
Typo fix
Code impr
Hello and thanks for your input. I'm actually trying to send chunkedresponse from SD files that are heavy (in terms of ESP32 : 100kB). May I ask for your help/more details on that one ? Thanks |
@simkard69 Hi, where did you read that phrase? Did you see the content of this PR? |
Hey, sorry it wasn't the latest version ... my bad. Anyway, I'm trying to serve files from SD and things get very slow. When I request a file of 161kB, it starts to download very slowly and ESP32 ends up crashing with this :
Here is my code :
Is there something I do wrong from your perspective ? |
Disclaimer: I am far from being a C++ expert. TBH I hate it, it's an ugly language where you shoot yourself into the foot and find it out a week later. I code in it just because of the ESP programming. I don't exactly understand why you use the
By that, you give up your CPU time, WD marks the thread is not blocked and you can happily continue with whatever you're doing. I call this basically in every loop i do on ESP32. |
By any chance this library can send data like on a chunked style without interrupting the rest of code (and that the loop() can continue to do its tasks) ? |
There could be a way, I don't know it... so far I always won the battle but yeah, it wasn't easy. I wish you strong will, faith and luck :-) |
Ok I think I found out my problem after all ... I'm quite ashamed by the root cause I finally found. So now I think I have to work on that before trying to do anything else.
|
Ok so it seems that I'm running into some weir problem. At first I thought the culprit was the 2GB SD card I put in which could be a slow model, so I switched to a U3, but it goes exactly the same ... where is the bottleneck ... ? From what I can see here, I definitely have a problem somewhere : https://www.instructables.com/Select-SD-Interface-for-ESP32/ |
You can bet SD is not the bottleneck, I just can't imagine that slow card 😄 As you may have noticed, I used SPIFFS in internal memory instead of SD card and it was slow as hell as well.Reading alone might be fine but streaming that into HTTP connection... |
Ok so after a little bit of research and posts it seems that v2.0.2 of arduino-esp32 created the problem I'm facing ... lovelyyy ! Here is a post I've created with some informations regarding that : espressif/arduino-esp32#6338 |
Well, applied bugfix on top of v2.0.2 of arduino-esp32 aaaaaaaaaaaaaand ... Magically, everything works as fast as it should ! I even ran again my benchmarks, here are my results using simple file.read() and file.write(value) :
Everything runs fine and smooth now, so happy that the error wasn't my culprit XDDDD For those who are running into the same problem, in v2.0.3 of arduino-esp32 this is corrected. Cheers to everyone ! |
Nice, glad to hear you solved it! |
Still not working here, even using the code from the linked project, by using the 404 callback |
#response_container_BBPPID{font-family: Tahoma, Geneva, sans-serif; font-size:11pt; color: #1F497D;} Thanks,Brian LoweBelleson LLC From: ***@***.***: April 28, 2022 5:34 AMTo: ***@***.***: ***@***.***: ***@***.***: Re: [me-no-dev/ESPAsyncWebServer] Readme update - file streaming (#770)
Still not working here, even using the code from the linked project, by using the 404 callback
Everything is very slow (almost unusable) and still getting the content length mismatch errors
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Who and what and when is the SPIFFS file closed? In my own code, I do it when I hit EOF, but not sure this code even does it. Or is it handled automatically somehow? |
Howdy,
I'd like to offer you an update of your readme.
First of all, thanks for the great job and that includes the readme. In spite of that, I believe I've found a way how to improve it a little bit :-)
TLDR: I want to avoid someone will spend hours solving such a stupid issue.
Full story:
I played with ESP8266 and tried to serve npm/webpack built JS app from it. The output was two big files (cca 70kB JS and 30kB CSS).
When I tried to use
server.serveStatic("/", SPIFFS, "/w").setDefaultFile("index.html")
, the files were served very slowly and sometimes not even completely - developer console in the browser has reported "Failed - content-length mismatch", like if the ESP just cut the connection before spilling the whole file. I believe it was because ESP8266 has too low RAM available and it was trying to buffer too big part of those files.I spent several hours with splitting those files into multiple ones which made things slightly better - usually, they were served just OK, even though very slowly. I tried to use
request->beginResponse
with callback instead (that seemed to me like the best/most intuitive/most efficient solution) however I've been fighting "exception 9".After some time, I have solved the issue - it's not exactly rocket science but I hate idea someone will repeat my mistakes and waste time on it when it can be written just fine in a very pleasant time. The application now works very well and it's not even necessary to split those resources files.
With this PR, I'm adding two new sections to your readme which should help someone facing the same issues and possibly repeating my steps.
I'd like to declare I'm not a C/C++ programmer so if the problem with lambda can be solved somehow better, I'd love to hear it and change the PR accordingly.