Error in WebSocket 2.0: byte indices must be integers or slices, not str
-
Hi All,
I'm getting WebSocket 2.0 data related issues intermittently.
2023-08-29 14:39:00,015 Websocket connected
2023-08-29 14:39:00,015 Connection opened, subscriptions done
2023-08-29 14:39:20,084 error from callback <bound method SmartWebSocketV2._on_pong of <SmartApi.smartWebSocketV2.SmartWebSocketV2 object at 0x000001A735A9FFD0>>: byte indices must be integers or slices, not str
2023-08-29 14:39:20,131 error from callback <bound method SmartWebSocketV2._on_close of <SmartApi.smartWebSocketV2.SmartWebSocketV2 object at 0x000001A735A9FFD0>>: SmartWebSocketV2._on_close() takes 2 positional arguments but 4 were given
2023-08-29 14:39:20,131 error from callback <bound method SmartWebSocketV2._on_close of <SmartApi.smartWebSocketV2.SmartWebSocketV2 object at 0x000001A735A9FFD0>>: SmartWebSocketV2._on_close() takes 2 positional arguments but 4 were givenThis is what I extracted from my logs. Can someone tell me why do I get this error: byte indices must be integers or slices, not str??
Flow: The App starts, shows streaming data, then I get this error and then the streaming socket data stops.
Please help!
-Sudip
-
<Error: SmartWebSocketV2._on_close() takes 2 positional arguments but 4 were given>
We can fix this error by updating _on_close method with additional arguments in SmartWebSocketV2.py file.
def _on_close(self, wsapp, close_status_code, close_msg):
This error is thrown because on_close method of websocket class takes multiple arguments which are missing in SmartWebSocket library. Example code:
https://websocket-client.readthedocs.io/en/latest/examples.html