File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 1
1
"""Logic to manage the WebSocket connection to the Matter server."""
2
+
2
3
from __future__ import annotations
3
4
4
5
import asyncio
@@ -121,7 +122,9 @@ async def receive_message_or_raise(self) -> MessageType:
121
122
raise ConnectionFailed ()
122
123
123
124
if ws_msg .type != WSMsgType .TEXT :
124
- raise InvalidMessage (f"Received non-Text message: { ws_msg .type } " )
125
+ raise InvalidMessage (
126
+ f"Received non-Text message: { ws_msg .type } : { ws_msg .data } "
127
+ )
125
128
126
129
try :
127
130
msg = parse_message (json_loads (ws_msg .data ))
Original file line number Diff line number Diff line change 1
1
"""Logic to handle a client connected over WebSockets."""
2
+
2
3
from __future__ import annotations
3
4
4
5
import asyncio
@@ -67,7 +68,7 @@ async def disconnect(self) -> None:
67
68
68
69
async def handle_client (self ) -> web .WebSocketResponse :
69
70
"""Handle a websocket response."""
70
- # pylint: disable=too-many-branches
71
+ # pylint: disable=too-many-branches,too-many-statements
71
72
request = self .request
72
73
wsock = self .wsock
73
74
try :
@@ -91,13 +92,17 @@ async def handle_client(self) -> web.WebSocketResponse:
91
92
while not wsock .closed :
92
93
msg = await wsock .receive ()
93
94
94
- if msg .type in (WSMsgType .CLOSE , WSMsgType .CLOSING ):
95
+ if msg .type in (WSMsgType .CLOSED , WSMsgType . CLOSE , WSMsgType .CLOSING ):
95
96
break
96
97
97
- if msg .type != WSMsgType .TEXT :
98
- disconnect_warn = "Received non-Text message. "
98
+ if msg .type == WSMsgType .ERROR :
99
+ disconnect_warn = f "Received error message: { msg . data } "
99
100
break
100
101
102
+ if msg .type != WSMsgType .TEXT :
103
+ self ._logger .warning ("Received non-Text message: %s" , msg .data )
104
+ continue
105
+
101
106
self ._logger .debug ("Received: %s" , msg .data )
102
107
103
108
try :
You can’t perform that action at this time.
0 commit comments