Navigation

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

    Kill or reset sws connection

    Python SDK
    0
    2
    3
    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.
    • W
      webiwork last edited by

      Currently there is a limit of 3 connections per client code for Websocket Streaming.

      As we know, i need to reset or kill previous create sws connection any method to kill this sws connection

      I am creating one strategy per deploy each deploy create one sws connection how to close previous sws connection i am unable to store sws connection object

      please help me Its big issue for me

      I am using python for this
      I know how to unsubscribe
      but how to store sws connection object and second time api call close the previous connection

      sws.unsubscribe(correlation_id, mode, token_list)
      cl = sws.close_connection()

      1 Reply Last reply Reply Quote 0
      • U
        usrikanth last edited by

        I assume your deployed strategy is running while you redeploy a new strategy, and this is leaving the websocket in previous deployment still alive, causing a leak.

        One simple way is to handle keyboard interrupt.
        https://stackoverflow.com/questions/4205317/capture-keyboardinterrupt-in-python-without-try-except

        Make sure you do the websocket connection inside a new thread. Use the main thread for the signal handler as shown in above url. Perform cleanup (unsubscribe+disconnect) in the signal handler function.

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