Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. Ekraj
    3. Posts
    E
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Ekraj

    • SmartWebSocketV2 reconnect only returns one ticker data after disconnect β€” all other tickers stop updating

      Hi all,

      I’m using SmartAPI’s SmartWebSocketV2 to stream multiple NSE tickers and generate live signals using Order Book Imbalance (OBI) and Volume Imbalance.

      Problem:

      Initially, the WebSocket streams all tickers correctly.

      After some time, I see repeated disconnects and reconnects:
      example :

      AXISBANK β€” Buy (Score: 0.606, Spread: 10.0, Mid: 106605.0)
      πŸ“ˆ DIVISLAB β€” Sell (Score: -0.9288, Spread: 50.0, Mid: 610025.0)
      πŸ“ˆ ADANIENT β€” Sell (Score: -0.923, Spread: 30.0, Mid: 227935.0)
      πŸ“ˆ LT β€” Sell (Score: -0.7807, Spread: 10.0, Mid: 369395.0)
      πŸ“ˆ HINDALCO β€” Hold (Score: -0.0862, Spread: 35.0, Mid: 70022.5)
      πŸ“ˆ ADANIPORTS β€” Buy (Score: 0.4086, Spread: 10.0, Mid: 131865.0)
      πŸ“ˆ JSWSTEEL β€” Hold (Score: -0.1565, Spread: 30.0, Mid: 105385.0)

      [W 250813 15:26:19 smartWebSocketV2:318] Attempting to resubscribe/reconnect (Attempt 1)...

      πŸ”Œ WebSocket Connected
      πŸ“ˆ BAJAJFINSV β€” Hold (Score: 0.054, Spread: 20.0, Mid: 191420.0)
      [W 250813 15:26:25 smartWebSocketV2:318]
      Attempting to
      resubscribe/reconnect (Attempt 2)...
      πŸ”Œ WebSocket Connected
      πŸ“ˆ BAJAJFINSV β€” Sell (Score: -0.4743, Spread: 20.0, Mid: 191420.0).

      current subscription logic:

      self.ws = SmartWebSocketV2(jwt_token, API_KEY, CLIENT_CODE, feed_token)
      self.ws.on_open = self.on_open
      self.ws.on_data = self.on_data
      self.ws.on_error = self.on_error

      def on_open(self, ws):
      print("βœ… WebSocket connected")
      self.ws.subscribe("stream_1", 3, [{"exchangeType": 1, "tokens": tokens}])

      i tried everything but it dosent fixed.
      is there anything im missing or bug im not abel to catch.

      posted in General Discussion
      E
      Ekraj