1
This commit is contained in:
@@ -147,10 +147,13 @@ class WebSocketClient:
|
||||
|
||||
# Read payload
|
||||
data = bytearray(length)
|
||||
view = memoryview(data)
|
||||
|
||||
# Use smaller chunks for readinto to avoid memory allocation issues in MicroPython
|
||||
pos = 0
|
||||
while pos < length:
|
||||
read_len = self.sock.readinto(view[pos:])
|
||||
chunk_size = min(length - pos, 512)
|
||||
chunk_view = memoryview(data)[pos:pos + chunk_size]
|
||||
read_len = self.sock.readinto(chunk_view)
|
||||
if read_len == 0:
|
||||
return None
|
||||
pos += read_len
|
||||
|
||||
Reference in New Issue
Block a user