-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ZLibCompressor issue leading to Websocket anomalies #7859
Labels
Comments
5 tasks
5 tasks
xiaohuanshu
added a commit
to xiaohuanshu/aiohttp
that referenced
this issue
Nov 22, 2023
Dreamsorcerer
pushed a commit
that referenced
this issue
Nov 24, 2023
bdraco
added a commit
to bdraco/aiohttp
that referenced
this issue
Nov 24, 2023
Fixes aio-libs#7859 (cherry picked from commit 86a2396)
bdraco
added a commit
to bdraco/aiohttp
that referenced
this issue
Nov 24, 2023
Fixes aio-libs#7859 (cherry picked from commit 86a2396)
Dreamsorcerer
pushed a commit
that referenced
this issue
Nov 24, 2023
Dreamsorcerer
pushed a commit
that referenced
this issue
Nov 24, 2023
xiangxli
pushed a commit
to xiangxli/aiohttp
that referenced
this issue
Dec 4, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
After upgrading aiohttp to version 3.9.0, I encountered an intermittent error where the browser reports an 'Invalid frame header' during websocket access.
On delving deeper, I found that the websocket module in aiohttp, when compressing the data, replaced zlib.compressobj with ZLibCompressor to support max_sync_chunk_size. The specific change can be traced to this commit: 586778f. However, ZLibCompressor was only initialized once in the WebSocketWriter and shared across multiple coroutines. However, its logic does not support usage in multiple coroutines. When different coroutines simultaneously call the websocket to send messages, the compressed results get mixed up, leading to frame inconsistencies.
After replacing ZLibCompressor with an older version of zlib.compressobj(mostly remove await on compressobj.compress to avoid coroutine switching), everything returned to normal.
To Reproduce
Expected behavior
correct compression
Logs/tracebacks
Python Version
Python 3.11.1
aiohttp Version
multidict Version
yarl Version
OS
macOS
Related component
Server
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: