Navigation

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

    Websocket unsubscribe from instrument

    Test
    2
    4
    77
    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.
    • F
      frog_26 last edited by

      I am able to subscribe and even send an additional instrument to be added to my subscription list. As in the example below, I first start streaming for 26000 data and after 5s, even 26009 data is sent along with 26000 data.

      token = "nse_cm|26000"
      ss.connect(threaded=True)
      time.sleep(5)
      token="nse_cm|26009
      ss.send_request(token, "mw")

      However, I want to unsubscribe from 26000 and I'm not able to do that. The docs say (https://smartapi.angelbroking.com/docs/WebSocket) that a blank string has to be sent to unsubscribe. I tried this piece of code but I still end up getting data for both instruments. What should I do to stop getting 26000 data and only get 26009 after a certain time? I cannot kill the script and restart, this has to be done within the code.

      token = "nse_cm|26000"
      ss.connect(threaded=True)
      time.sleep(5)
      ss.send_request("", "mw")
      token="nse_cm|26009
      ss.send_request(token, "mw")

      1 Reply Last reply Reply Quote 0
      • F
        frog_26 last edited by

        @admin has the unsubscribe feature been released yet?

        A 1 Reply Last reply Reply Quote 0
        • A
          admin @frog_26 last edited by

          Hi @frog_26 we cannot unsubscribe a single instrument from the websocket.

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

            hi @frog_26 please go through this thread
            https://smartapi.angelbroking.com/topic/51/how-to-unsubscribe-symbol-from-websocket?_=1618296924024

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