Navigation

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

    Websocket of Order Status is not working.

    General Discussion
    0
    6
    52
    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.
    • A
      aakash2610 last edited by

      I want to use web socket of order status mentioned in: https://smartapi.angelbroking.com/docs/WebSocketOrderStatus. But the URL mentioned in it seems to be not responding at all. My script is erroring out saying Connection to remote host was lost.

      Can you please check what is the issue?

      Code I am using to connect:

      self.ROOT_URI = 'wss://smartapisocket.angelbroking.com/websocket'
      ROOT_URL = f"{self.ROOT_URI}?jwttoken={self.jwttoken}&clientcode={self.client_code}&apikey={self.apiKey}"
      print(ROOT_URL)
      self.ws = websocket.WebSocketApp(ROOT_URL,
            #  header=headers,
            on_message=self.__on_message,
            on_close=self.__on_close,
            on_open=self.__on_open,
            on_error=self.__on_error
            )
      self.ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
      
      A 1 Reply Last reply Reply Quote 0
      • A
        aakash2610 last edited by

        @admin, any update on this?

        M 1 Reply Last reply Reply Quote 0
        • M
          Moderator_2 @aakash2610 last edited by

          Hi @aakash2610 ,

          Apologies for delayed response.
          The endpoint "websocket" has been deprecated from our end.
          Kindly refer to the below documentation for the updated endpoints.
          https://smartapi.angelbroking.com/docs/WebSocket2

          Thanks & Regards,
          SmartAPI team

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

            @Moderator_2, can you please share a working sample code for Websocket Order Status using Python SDK or general python code?

            M 1 Reply Last reply Reply Quote 0
            • M
              Moderator_2 @aakash2610 last edited by

              @aakash2610

              Apologies for delayed response.
              Please find the sample code for websocket below.

              *AUTH_TOKEN = "token"
              API_KEY = "key"
              CLIENT_CODE = "code"
              FEED_TOKEN = "feed_token"
              correlation_id = "abc123"
              action = 1
              mode = 3
              token_list = [{"exchangeType": "1", "tokens": ["438"]}, {"exchangeType": "1", "tokens": ["13528"]}, {"exchangeType": "1", "tokens": ["2303"]}]

              #retry_strategy=0 for simple retry mechanism
              sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN)

              def on_data(wsapp, message):
              logger.info("Ticks: {}".format(message))
              # close_connection()

              def on_control_message(wsapp, message):
              logger.info(f"Control Message: {message}")

              def on_open(wsapp):
              logger.info("on open")
              some_error_condition = False
              if some_error_condition:
              error_message = "Simulated error"
              if hasattr(wsapp, 'on_error'):
              wsapp.on_error("Custom Error Type", error_message)
              else:
              sws.subscribe(correlation_id, mode, token_list)
              # sws.unsubscribe(correlation_id, mode, token_list1)

              def on_error(wsapp, error):
              logger.error(error)

              def on_close(wsapp):
              logger.info("Close")

              def close_connection():
              sws.close_connection()

              Assign the callbacks.

              sws.on_open = on_open
              sws.on_data = on_data
              sws.on_error = on_error
              sws.on_close = on_close
              sws.on_control_message = on_control_message

              sws.connect()*

              Thanks & Regards,
              SmartAPI team

              L 1 Reply Last reply Reply Quote 0
              • L
                lgupta1 @Moderator_2 last edited by

                @Moderator_2 said in Websocket of Order Status is not working.:

                action = 1
                mode = 3
                token_list = [{"exchangeType": "1", "tokens": ["438"]}, {"exchangeType": "1", "tokens": ["13528"]}, {"exchangeType": "1", "tokens": ["2303"]}]

                Can you explain what these variables are and what are their possible values?

                • action
                • mode
                • token_list
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post