Open evanderkuy opened 5 months ago
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.
My nginx webserver, with a new firmware file, does not have the content-length header response on the first request.
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?
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.
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