Skip to content

Fix ONVIF camera connection issues by disabling aiohttp auto-decompression #138

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

Closed
wants to merge 2 commits into from

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Aug 18, 2025

Summary

This PR fixes connection issues with ONVIF cameras (particularly those using Thingino firmware) that were introduced in v4.0.3. The previous fix for double gzip decompression (#135) caused compatibility issues with certain cameras.

Problem

The previous approach filtered out the Content-Encoding header after aiohttp automatically decompressed responses. This caused issues with cameras that:

  • Send uncompressed responses despite Content-Encoding headers
  • Have non-standard compression implementations
  • Expect the Content-Encoding header to be preserved

Solution

Instead of filtering headers after aiohttp processes the response, this PR:

  1. Disables automatic decompression in aiohttp by adding auto_decompress=False to all requests
  2. Preserves all headers including Content-Encoding
  3. Lets zeep handle decompression based on the Content-Encoding header

Changes

  • Added auto_decompress=False parameter to session.post() and session.get() calls
  • Removed the _filter_headers() method that was stripping Content-Encoding headers
  • Updated tests to reflect the new behavior where Content-Encoding is preserved

Testing

  • All existing tests pass
  • Updated gzip-related tests to verify Content-Encoding header is preserved
  • Tested with both compressed and uncompressed responses

Related Issues

Impact

This change ensures compatibility with all ONVIF cameras while still preventing double decompression issues. The responsibility for decompression is now properly delegated to zeep, which can handle it correctly based on the actual Content-Encoding header.

Copy link

codecov bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
onvif/zeep_aiohttp.py 96.51% <100.00%> (-0.12%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco bdraco closed this Aug 20, 2025
@bdraco bdraco deleted the no_auto_decompress branch August 20, 2025 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ONVIF don’t work after 2025.8.2 update with Xiaomi 2K camera using custom Thingino firmware
1 participant