Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Error in WebSocket 2.0: byte indices must be integers or slices, not str

    Python SDK
    0
    2
    30
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      projectSB last edited by

      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 given

      This 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

      1 Reply Last reply Reply Quote 0
      • A
        ashigro last edited by ashigro

        <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

        1 Reply Last reply Reply Quote 1
        • First post
          Last post