micropython / micropython/micropython-lib
aiohttp: ws: frame not fully received/read if large
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Description
I noticed how large payload are cut-off when using the high-level receive-functions provided by the websocket implementation of aiohttp.
The following debug statements show the observed truncation:
diff --git a/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py b/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py
index 6e0818c..34c7b08 100644
--- a/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py
+++ b/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py
@@ -203,7 +203,9 @@ class WebSocketClient:
if has_mask: # pragma: no cover
mask = await self.reader.read(4)
+ print("READING BYTES:", length)
payload = await self.reader.read(length)
+ print("READ BYTES:", len(payload))
if has_mask: # pragma: no cover
payload = bytes(x ^ mask[i % 4] for i, x in enumerate(payload))
return opcode, payload
Output from test run supposed to receive a >1.5KiB payload:
READING BYTES: 1594
READ BYTES: 1436
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in aiohttp/aiohttp_ws.py at WebSocketClient and the frame-reading path around reader.read(length). Reproduce the reported case with a payload over 1.5 KiB and compare the requested frame length with the bytes returned; done when the high-level receive functions return the complete payload.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100