Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Always write error on first attempt OTA ESP32 S3 #12

Open
evanderkuy opened this issue May 30, 2024 · 7 comments
Open

Always write error on first attempt OTA ESP32 S3 #12

evanderkuy opened this issue May 30, 2024 · 7 comments

Comments

@evanderkuy
Copy link

When I try to update to a new firmware version, I always get a write error (code 2). If try it again I will receive error code 4. Than when I reboot, do an update and it will succeed. What am I missing?

Etienne

@evanderkuy evanderkuy changed the title Always write error (2) Always write error on first attempt May 30, 2024
@evanderkuy
Copy link
Author

I found out it only happens on the first update (after i upload the file to the web server). It is caused by int totalLength = http.getSize(); resulting in -1. (Maybe content-length header missing?

When I use two devices, flash them with same version. Then I upload a new version to web server. The first device I want to update via OTA gives the error code 2. Reboot and update via OTA is successful.

After that, I use the second device and do the OTA update, it works perfect immediately. I think it has something to do with the web server. Remember something from the past when deploying a new version of a ASP application the first request always failed. Will find out.

@evanderkuy evanderkuy changed the title Always write error on first attempt Always write error on first attempt OTA ESP32 S3 May 31, 2024
@evanderkuy
Copy link
Author

My nginx webserver, with a new firmware file, does not have the content-length header response on the first request.

@mikalhart
Copy link
Owner

Thanks for the analysis, @evanderkuy. Is there a solution to this problem that we can add to the library? Perhaps infer the content-length somehow?

@evanderkuy
Copy link
Author

What is annoying now, is that I have to reboot the device to make the second request, or else I get error 4 messages for every try. For an end-user on a device, I can image they will try again without rebooting. Tried to http.end(); but that did not work. Haven't looked further into it. I will try a different server to host the firmware files. It is not a big problem as when I publish I can make the first request my selves.

@mrcodetastic
Copy link

This is likely a Chunked HTTP response issue. You don't get a content-length with this.

Refer to my latest pull request that explicitly requests the HTTP call be downgraded to HTTP 1.0.

I've had all sorts of issues over the years with basic end-points on servers that do this chunking.

@mrcodetastic
Copy link

Have implemented fix in my fork @ https://github.com/mrcodetastic/ESP32-OTA-Pull/tree/main

@evanderkuy
Copy link
Author

Thank you!!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants