Navigation

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

    not receiving proper WebSocket data

    Test
    5
    23
    179
    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
      pavank last edited by

      I’m trying to access data from web socket using smartapi-python, but I’m only receiving heartbeat data and some other data. Please do needful.

      Request:
      client_code="********" #client code is set in actual script
      task="mw"
      token="nsc_cm|15083"
      ss = WebSocket(feed_token , client_code)
      def on_tick(ws, tick):
      for feed_data in tick:
      print(feed_data)
      def on_connect(ws, response):
      print("connecting websocket")
      print(task)
      ws.send_request(token,task)

      def on_close(ws, code, reason):
      print("closing websocket")
      ws.stop()

      ss.on_ticks = on_tick
      ss.on_connect = on_connect
      ss.on_close = on_close
      ss.connect( )

      Note: login successful and feed token set

      Response:
      {'ak': 'ok', 'msg': 'connected', 'task': 'cn'}
      {'ak': 'ok', 'msg': 'mw', 'task': 'mw'}
      {'ak': 'ok', 'msg': 'heartbeat', 'task': 'hb'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:05'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:06'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:07'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:08'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:09'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:10'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:11'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:12'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:13'}
      {'name': 'tm', 'tvalue': '12/03/2021 10:13:14'}

      A D 2 Replies Last reply Reply Quote 0
      • A
        admin @pavank last edited by

        hi @pavank web socket is working fine from our end.1.PNG

        S P 2 Replies Last reply Reply Quote 0
        • S
          Surya 1 @admin last edited by

          @admin

          I am running from morning.. I don't see any issue either

          1 Reply Last reply Reply Quote 0
          • N
            nirav last edited by

            @admin
            Hi sir
            I tried to get live data by web socket..
            I tried reliance and many other but every time I recieved only tcs tick data.
            What is happening guide me. Tnx

            A S 2 Replies Last reply Reply Quote 0
            • A
              admin @nirav last edited by

              hi @nirav we have noticed your issue we will revert you back.

              N 1 Reply Last reply Reply Quote 0
              • P
                pavank @admin last edited by

                @admin, i found the issue, in token i have misspelled nse_cm, but i think there should an error msg stating invalid token.................

                1 Reply Last reply Reply Quote 0
                • N
                  nirav @admin last edited by

                  @admin ok sir tnx
                  I'm waiting for your answer.

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

                    Hi @nirav websocket is working fine from our end.

                    N 1 Reply Last reply Reply Quote 0
                    • S
                      Surya 1 @nirav last edited by

                      @nirav

                      can you please share the code and your sdk version ( if you are using python )

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

                        @rajanprabu @ nirav
                        kindly generate feed token and use below code.

                        from smartapi import WebSocket
                        FEED_TOKEN= "xxxxxxxx"
                        CLIENT_CODE="xxxxxxx"
                        token="nse_cm|2885&nse_cm|1594&nse_cm|11536"
                        #"nse_cm|2885&nse_cm|1594&nse_cm|11536"

                        ss = WebSocket(FEED_TOKEN, CLIENT_CODE)

                        def on_tick(ws, tick):
                        print("Ticks: {}".format(tick))

                        def on_connect(ws, response):
                        ws.send_request(token)

                        def on_close(ws, code, reason):
                        ws.stop()

                        Assign the callbacks.

                        ss.on_ticks = on_tick
                        ss.on_connect = on_connect
                        ss.on_close = on_close

                        ss.connect( )`

                        S N 2 Replies Last reply Reply Quote 0
                        • S
                          Surya 1 @admin last edited by Surya 1

                          @admin

                          @admin said in not receiving proper WebSocket data:

                          ws.send_request(token)

                          for SDK version 1.2.2 onwards this needs to be

                          ws.send_request(token,task)

                          where task is task="mw", #'mw'|'sfi'|'dp'

                          1 Reply Last reply Reply Quote 0
                          • N
                            nirav @admin last edited by

                            @admin ok sir tnx issue is sloved. bt
                            open interest live datafeed avaliable for nifty index ?
                            if not so how i get it ?
                            tnx

                            N 1 Reply Last reply Reply Quote 0
                            • N
                              nirav @nirav last edited by

                              @admin
                              I try to get by web socket
                              (Ex= nifty 15000 ce open interest)

                              James Bond 1 Reply Last reply Reply Quote 0
                              • James Bond
                                James Bond @nirav last edited by James Bond

                                @nirav

                                No, OI is not streamed via WebSocket. It's yet to be added in WebSocket response.

                                “Bond. James Bond.”

                                1 Reply Last reply Reply Quote 0
                                • James Bond
                                  James Bond last edited by

                                  @admin
                                  Can you give any rough estimate when will you start streaming OI ?

                                  “Bond. James Bond.”

                                  1 Reply Last reply Reply Quote 0
                                  • N
                                    nirav @admin last edited by

                                    @admin
                                    hii sir very good noon
                                    why i recive a heart beat error msg on live web socket data streaming. any solution for this plz tell me . its very important for me.
                                    tnx

                                    A S 2 Replies Last reply Reply Quote 0
                                    • A
                                      admin @nirav last edited by

                                      HI @nirav we have noticed your query we will update you on this.

                                      1 Reply Last reply Reply Quote 0
                                      • S
                                        Surya 1 @nirav last edited by

                                        @nirav

                                        This normally happens with network drop. If you are using new python SDK, you may potentially overcome this.

                                        N 1 Reply Last reply Reply Quote 0
                                        • N
                                          nirav @Surya 1 last edited by

                                          @rajanprabu
                                          sir i have install python sdk just tomorrow, so its a latest. till i getting heart beat. any solution for this by api team or not. my deadline is very close. suggest me asap

                                          tnx

                                          S A 2 Replies Last reply Reply Quote 0
                                          • S
                                            Surya 1 @nirav last edited by

                                            @nirav

                                            Its hard to suggest with fewer details available. Are you running it on the cloud or at home with Wifi ? WiFi drop can also cause this.

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