Navigation

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

    Error info: Connection to remote host was lost. Connection to remote host was lost.

    General Discussion
    websocket
    7
    32
    197
    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.
    • tester12345
      tester12345 @tester12345 last edited by

      @admin any update on this?

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

        @admin Min of 2, max I have tried is 3 scrips.

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

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • A
            admin @s4ntosh last edited by

            Hi @s4ntosh We reported this to our team we will update you on this.

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

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • A
                abhijith last edited by

                @admin

                Facing the same issue.

                Additionally also receiving heartbeat failed error.
                11.PNG

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

                  Dear @abhijith We are aware of this we will update once it get fixed.

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

                    hi @anuragbaheti which version of sdk you are using.

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

                      @admin version 1.2.8 of smartapi-python

                      518e6121-1a76-429a-9c7f-5f9f050149dc-image.png

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

                        HI @anuragbaheti Ok noted.

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

                          from smartapi import SmartWebSocket
                          import pickle
                          from smartapi import SmartConnect
                          from time import sleep
                          from datetime import datetime as dt
                          
                          
                          def get_feedtoken ():
                              file = f'cache/ft_{dt.now().strftime("%d_%m_%Y")}.cache'
                              token = pickle.load(open(file , 'rb') )
                              return [( k , v ) for k, v in token.items() ][0]
                          
                          
                          def on_message(ws, message):
                              global count , token , ts
                              try:
                                  # print(message)
                                  for msg in message:
                                      ts['timestamp'] = msg['tvalue'] if 'tvalue' in msg.keys() else ts['timestamp']
                                      msg['ltt'] = ts['timestamp'] if 'ltt' in msg.keys() and msg['ltt']=='NA' else msg['ltt']
                                      if not 'tvalue' in msg.keys():
                                          msg.update(ts)
                                          print(msg)
                              except Exception as e:
                                  traceback.print_exc()
                                  exit()
                          
                          def on_open(ws):
                              global task , token
                              print("on open")
                              ss.subscribe(task,token)
                              print("subscribed")
                          
                          def on_error(ws, error):
                              print(error)
                          
                          def on_close(ws):
                              print("Close")
                          
                          
                          CLIENT_CODE ,FEED_TOKEN   = get_feedtoken ()
                          token="nse_cm|26009"
                          task="mw"   # mw|sfi|dp
                          ts = {'timestamp' : None }
                          ss = SmartWebSocket(FEED_TOKEN, CLIENT_CODE)
                          ss._on_open = on_open
                          ss._on_message = on_message
                          ss._on_error = on_error
                          ss._on_close = on_close
                          
                          while True:
                              ss.connect()
                          
                          

                          some guys are dm me about to code. for handling about such scenario. this egs works fine. u need to reconnect again when it disconnected. no other options

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

                            @admin the problem still exists. i have log . i have took the count how many time it got disconnected . which is 42 time. please fix the problem as soon as possible.

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

                              HI @nahas_n We have reported this to our team.We will update you.

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