Skip to content

Commit 4f67c95

Browse files
Handle unexpected WebSocket close frames sent by server (Fixes #292)
1 parent 45e97b8 commit 4f67c95

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/engineio/asyncio_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,13 @@ async def _read_loop_websocket(self):
520520
p = await asyncio.wait_for(
521521
self.ws.receive(),
522522
timeout=self.ping_interval + self.ping_timeout)
523-
p = p.data
524-
if p is None: # pragma: no cover
523+
if not isinstance(p.data, (str, bytes)): # pragma: no cover
524+
self.logger.warning(
525+
'Server sent unexpected packet %s data %s, aborting',
526+
str(p.type), str(p.data))
525527
await self.queue.put(None)
526528
break # the connection is broken
529+
p = p.data
527530
except asyncio.TimeoutError:
528531
self.logger.warning(
529532
'Server has stopped communicating, aborting')

0 commit comments

Comments
 (0)