Navigation

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

    HeartBeats Failed

    General Discussion
    5
    40
    291
    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.
    • S
      Surya 1 last edited by

      Hi @admin and fellow boarders,

      For the last two days,

      Im getting this HearBeats Failed message

      DRREDDY, 2021-01-14 14:10:00, 5288.05, 5288.9, 5287.25, 5287.25
      HDFCLIFE, 2021-01-14 14:09:00, 707.35, 707.35, 707.15, 707.15
      HEROMOTOCO, 2021-01-14 14:10:00, 3256.8, 3256.8, 3256.55, 3256.55
      BHARTIARTL, 2021-01-14 14:10:00, 581.45, 581.45, 581.45, 581.45
      BRITANNIA, 2021-01-14 14:10:00, 3674.0, 3674.0, 3674.0, 3674.0
      TITAN, 2021-01-14 14:10:00, 1485.4, 1485.5, 1485.4, 1485.5
      ICICIBANK, 2021-01-14 14:10:00, 551.9, 552.15, 551.9, 552.1
      ITC, 2021-01-14 14:10:00, 213.9, 213.9, 213.85, 213.85
      NESTLEIND, 2021-01-14 14:09:00, 18132.9, 18132.9, 18131.1, 18131.1
      EICHERMOT, 2021-01-14 14:10:00, 2871.45, 2871.45, 2868.6, 2868.6
      ULTRACEMCO, 2021-01-14 14:10:00, 5572.05, 5574.4, 5570.0, 5570.0
      BPCL, 2021-01-14 14:10:00, 419.0, 419.15, 419.0, 419.15
      SUNPHARMA, 2021-01-14 14:10:00, 605.1, 605.1, 605.05, 605.05
      ASIANPAINT, 2021-01-14 14:10:00, 2662.5, 2663.2, 2662.5, 2663.2
      POWERGRID, 2021-01-14 14:08:00, 204.45, 204.45, 204.45, 204.45
      SBILIFE, 2021-01-14 14:08:00, 924.65, 924.65, 924.65, 924.65
      GRASIM, 2021-01-14 14:10:00, 1020.2, 1020.6, 1020.1, 1020.1
      IOC, 2021-01-14 14:09:00, 101.3, 101.35, 101.3, 101.35
      JSWSTEEL, 2021-01-14 14:10:00, 395.2, 395.2, 395.05, 395.05
      AXISBANK, 2021-01-14 14:10:00, 678.75, 678.9, 678.75, 678.9
      DIVISLAB, 2021-01-14 14:10:00, 3700.0, 3700.0, 3699.85, 3699.9
      SBIN, 2021-01-14 14:10:00, 307.7, 307.7, 307.7, 307.7
      UPL, 2021-01-14 14:10:00, 511.75, 511.75, 511.75, 511.75
      NTPC, 2021-01-14 14:10:00, 101.85, 101.9, 101.85, 101.9
      INDUSINDBK, 2021-01-14 14:10:00, 969.45, 969.45, 969.45, 969.45
      LT, 2021-01-14 14:10:00, 1380.85, 1381.0, 1380.85, 1381.0
      KOTAKBANK, 2021-01-14 14:10:00, 1898.0, 1898.0, 1898.0, 1898.0
      SHREECEM, 2021-01-14 14:10:00, 24775.35, 24775.35, 24775.35, 24775.35
      HINDALCO, 2021-01-14 14:10:00, 261.65, 261.65, 261.65, 261.65
      RELIANCE, 2021-01-14 14:10:00, 1963.75, 1963.75, 1963.5, 1963.5
      BAJAJFINSV, 2021-01-14 14:10:00, 8741.5, 8744.6, 8741.5, 8744.6
      BAJFINANCE, 2021-01-14 14:10:00, 4880.0, 4880.9, 4879.95, 4879.95
      ADANIPORTS, 2021-01-14 14:10:00, 534.5, 534.8, 534.5, 534.8
      TATASTEEL, 2021-01-14 14:10:00, 704.35, 704.5, 704.35, 704.5
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      HeartBeats Failed
      

      Am I the only one getting this message ? It could be my code ( live trading using Backtrader ) but I just wanted to know if anyone else has the same issue.

      Thanks

      punit G 2 Replies Last reply Reply Quote 0
      • punit
        punit @Surya 1 last edited by

        @rajanprabu , At what time the heartbeat failed for you?

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

          @dheepi

          I run a cron job to start my algo because I live in a different time zone. Program started at 9:15 and ran fine till 10:33 then it gave heartbeats failed message.

          Then I tried manually to run and its started appearing randomly after some time.

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

            @rajanprabu Very similar to what happened to me today.

            -> Login (Generate session) @ 7AM - OK
            -> When the cron started Websocket at 9.15 AM, the token got expired
            -> Then I generated new token at 11:12 and started websocket streaming again - OK
            -> But the streaming ended at 14:09 got stopped - I did not check the heartbeat, but probably that is the reason

            Looks like the token i getting expired after sometime. say 2.5 hrs by estimate.

            I raised this with @Bhaveshsjain @admin today morning . lets wait for the analysis.

            PS: All my jobs are scheduled in a scheduler

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

              Hi @Ashok @rajanprabu , we are reviewing this.

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

                @rajanprabu @Ashok We have connected the websocket today morning and till now it's working fine. If we get a disconnection before 3.30, will identify and resolve the issue.

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

                  @admin

                  I have tested today and I had the same error. Please find the test script below. Im using threaded=True

                  from smartapi import WebSocket 
                  import json
                  import datetime
                  import time
                  
                  with open('AB/ab_user.json') as f:
                      data = json.load(f)
                  client_code = data['client_code']
                  
                  with open('AB/ab_tokens.json') as f:
                      data = json.load(f)
                  feed_token = str(data['feedToken'])
                  
                  token = "nse_cm|3456&nse_cm|7229&nse_cm|1594&nse_cm|3787&nse_cm|1330&nse_cm|10999&nse_cm|4717&nse_cm|13538&nse_cm|694&nse_cm|2031&nse_cm|2475&nse_cm|1394&nse_cm|11536&nse_cm|20374&nse_cm|1333&nse_cm|881&nse_cm|467&nse_cm|1348&nse_cm|10604&nse_cm|547&nse_cm|3506&nse_cm|4963&nse_cm|1660&nse_cm|17963&nse_cm|910&nse_cm|11532&nse_cm|526&nse_cm|3351&nse_cm|236&nse_cm|14977&nse_cm|21808&nse_cm|1232&nse_cm|1624&nse_cm|11723&nse_cm|5900&nse_cm|10940&nse_cm|3045&nse_cm|11287&nse_cm|11630&nse_cm|5258&nse_cm|11483&nse_cm|1922&nse_cm|3103&nse_cm|1363&nse_cm|2885&nse_cm|16675&nse_cm|317&nse_cm|15083&nse_cm|3499"
                  
                  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(threaded=True)
                  
                  while True:
                      pass
                  
                  1 Reply Last reply Reply Quote 0
                  • S
                    Surya 1 last edited by

                    @Ashok was it running ok for you today ?? No HeartBeats Failed message ?

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

                      @rajanprabu my websocket worked just fine today no failures. I was seeing tick data till 15.30.
                      But I forgot to log the heartbeat message to see if there are any failures.
                      PS: I am not using threaded ticker

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

                        @Ashok Im also wondering if that is the root cause of the problem. But in my code I have a streamer class which emits the ticks. This I run in one thread and other things that I do in parallel using threads. This functionality is crucial.

                        I hope @admin and team had a look at it.

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

                          Hi @rajanprabu , Hope your issue is resolved. If not, please share your contact details on api@angelbroking.com

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

                            @admin

                            I have tested without running them on threads separate threads. It went well today.

                            all my troubles appear when I use

                            ss.connect(threaded=True)
                            

                            I also think this is the limitation on in unix based systems. I have modified the websocket.py to have reactor.run(installSignalHandlers=False) even one doesnt use the threaded=True.

                            In case if this helps anyone.

                            1 Reply Last reply Reply Quote 0
                            • G
                              gkmeena @Surya 1 last edited by

                              @rajanprabu hi i want data like this can you give me code?

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

                                @gkmeena

                                Which code ?

                                G 1 Reply Last reply Reply Quote 0
                                • G
                                  gkmeena @Surya 1 last edited by

                                  @rajanprabu
                                  ![alt text](Screenshot (45).png code for this kind of output)

                                  R 1 Reply Last reply Reply Quote 0
                                  • R
                                    rahul4019 @gkmeena last edited by

                                    @rajanprabu @admin
                                    I am getting the heartbeat failed message.
                                    I am wondering how do you re-establish the connection?
                                    Also even after the program has ended the heartbeat failed message keeps popping up.

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

                                      Hi @PandaTrade we will soon our web socket code we will keep you updated on this.

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

                                        @PandaTrade said in HeartBeats Failed:

                                        Also even after the program has ended the heartbeat failed message keeps popping up.

                                        Thats mainly because Heartbeart connection is running in separate thread. I have a parallel script running to check if there is any HB failure message. Once it find it will stop and restart the script. Of course this can be a issue if you use indicators using past data.

                                        1 Reply Last reply Reply Quote 0
                                        • R
                                          rahul4019 last edited by

                                          hi @admin
                                          have you fixed your Tickdata web socket code?
                                          To me it looks like working. Just want to confirm what are the fixes that you have done?

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

                                            @PandaTrade

                                            They released a new SDK.. But yet to try it.. will try in the evening with MCX data.

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