Skip to content

aiohttp: ws: frame not fully received/read if large #1037

@mirko

Description

@mirko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions