tobozo / ESP32-targz

🗜️ An Arduino library to unpack/uncompress tar, gz, and tar.gz files on ESP32 and ESP8266
Other
118 stars 15 forks source link

[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0. failed at retry --> NEVER RECOVERS #26

Closed dforsyth1 closed 3 years ago

dforsyth1 commented 3 years ago

Heya,

Thought we were good but I didn't test a failure case. Seems when the retry fails, although you return -1, you never bail back to the caller.

Caller snippet:

...
GzUnpacker *GZUnpacker = new GzUnpacker();

GZUnpacker->haltOnError( true ); // stop on fail (manual restart/reset required)
GZUnpacker->setupFSCallbacks( targzTotalBytesFn, targzFreeBytesFn ); // prevent the partition from exploding, recommended
GZUnpacker->setGzProgressCallback( BaseUnpacker::defaultProgressCallback ); // targzNullProgressCallback or defaultProgressCallback
GZUnpacker->setLoggerCallback( BaseUnpacker::targzPrintLoggerCallback  );    // gz log verbosity

//
// Read from the stream and decompress to the free OTA partition, then reset
//
if (!GZUnpacker->gzStreamUpdater(http.getStreamPtr(), UPDATE_SIZE_UNKNOWN) ) {
  Serial.printf("gzHTTPUpdater failed with return code #%d\n", GZUnpacker->tarGzGetError());
}

Never gets to GZUnpacker with the following log output:

Connected to Wifi: (Christopher) MAC: (40:F5:20:4A:0B:94) IP: (192.168.1.65) ESP hostname: (Box-5024-v2014), DNS server: (192.168.1.1)
Getting IP for URL: (digest.lagunaresearch.com)
Found IP for (digest.lagunaresearch.com): (54.153.65.87)
Attempting to connect to https://digest.lagunaresearch.com/chris.bin.gz
HTTP.begin successful for https://digest.lagunaresearch.com/chris.bin.gz
HTTP.get successful for https://digest.lagunaresearch.com/chris.bin.gz, size of file reported as 782953
[GZUpdater] Starting update with unknown binary size
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
[E][ssl_client.cpp:33] _handle_error(): [data_to_read():270]: (-76) UNKNOWN ERROR CODE (004C)
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
Wifi is disconnected, status is (6), attempting to reconnect
Attempting to connect to Wifi Station (Christopher) with password (6646664666)
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
Connected to Wifi: (Christopher) MAC: (40:F5:20:4A:0B:94) IP: (192.168.1.65) ESP hostname: (Box-5024-v2014), DNS server: (192.168.1.1)
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
[E][ESP32-targz-lib.cpp:1015] gzReadSourceByte(): readSourceByte read error, available is 0.  failed at retry
... forever :(

So I modified GzUnpacker::gzReadSourceByte to just return -1 and got this:

Attempting to connect to https://digest.lagunaresearch.com/firmware.bin.gz
HTTP.begin successful for https://digest.lagunaresearch.com/firmware.bin.gz
HTTP.get successful for https://digest.lagunaresearch.com/firmware.bin.gz, size of file reported as 782942
[GZUpdater] Starting update with unknown binary size
bad id bytes
[E][ESP32-targz-lib.cpp:1091] gzUncompress(): [ERROR] in gzUncompress: uzlib_gzip_parse_header failed (response code -3!
[E][ESP32-targz-lib.cpp:1463] gzStreamUpdater(): gzHTTPUpdater returned error code -105
[E][ESP32-targz-lib.cpp:108] targz_system_halt(): System halted after error code #-105

My expectation (fair to say perhaps anyone's) is that it would return false.

Of course when it succeeds, it's beautiful.

I can revert back to my cloned repo with the retry before your refactor. Prefer to stay current. Let me know your thoughts...

dforsyth1 commented 3 years ago

Will re-post as me