You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: on_message_async crashes on non-object JSON messages (e.g. heartbeats) #123
WsClient.on_message_async crashes with AttributeError: 'str' object has no attribute 'get' when the WebSocket server sends a non-object JSON message (e.g. a string heartbeat).
Root Cause
The sync on_message method correctly handles raw string messages:
But the async on_message_async skips the type check after parsing:
asyncdefon_message_async(self, ws, message):
message=json.loads(message)
message_type=message.get("type") # crashes if json.loads returns a str
When the server sends a JSON string value (e.g. "heartbeat"), json.loads('"heartbeat"') returns "heartbeat" (a str), and str has no .get() method.
Impact
This causes run_async() to raise an unhandled AttributeError, disconnecting the WebSocket client. In a reconnect loop, this results in a permanent crash cycle with no useful work being done.
Suggested Fix
Add an isinstance check after json.loads, matching the pattern in on_message:
Activity
fix: resolve 7 open SDK issues (elliottech#15, elliottech#21, elliott…