danielfernau / unifi-protect-video-downloader

Tool for downloading footage from a local UniFi Protect system
https://ui-protect-dl-docs.danielfernau.com/
MIT License
477 stars 55 forks source link

Fix unhandled exception in download_file.py after response error 104 (Connection reset by peer) #325

Closed CodeChief closed 1 year ago

CodeChief commented 1 year ago

Changed buffer size in "response.iter_content()" from hard-coded "4096" to "None" which according to models.py documentation uses a dynamic buffer in stream mode rather than fixed buffer (which appeared to have caused an overrun in this situation).

This error started to appear after recent UniFi firmware update versions (switching from production to early access firmware did not fix it, appears to be new behaviour). I also checked the computer where the downloads run to ensure it has all updates including Docker Desktop and network drivers, tested different network settings for stability, different adapters (LAN or WiFi) even directly attached to the UniFi DM SE where the UniFi NVR was locally connected (different network cables too).

The error situation appears to be new behaviour. The only special case could be that the cameras (video stream being downloaded) had disconnects or rebooted for updates multiple times on the day being downloaded.

codecov[bot] commented 1 year ago

Codecov Report

Merging #325 (fc7aedf) into master (ecab994) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #325   +/-   ##
=======================================
  Coverage   53.19%   53.19%           
=======================================
  Files          23       23           
  Lines         720      720           
=======================================
  Hits          383      383           
  Misses        337      337           
Flag Coverage Δ
unittests 53.19% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
protect_archiver/downloader/download_file.py 45.71% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more