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


  • websocket disconnected after some time.

    for egs

    {'ap': '34984.60', 'bp': '35135.05', 'bq': '75', 'bs': '100', 'c': '34929.35', 'cng': '212.55', 'e': 'nse_fo', 'lo': '34830.00', 'ltp': '35141.90', 'ltq': '25', 'ltt': '10/06/2021 13:19:58', 'name': 'sf', 'nc': '00.6085', 'sp': '35141.95', 'tbq': '149400', 'tk': '48506', 'to': '60974659340.00', 'tsq': '108200', 'v': '1742900'}
    326
    Error info: Connection to remote host was lost.
    Connection to remote host was lost.
    

    please check the issues in the server side.


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


  • @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.


  • 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


  • HI @anuragbaheti Ok noted.


  • @admin version 1.2.8 of smartapi-python

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


  • hi @anuragbaheti which version of sdk you are using.


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


  • @admin

    Facing the same issue.

    Additionally also receiving heartbeat failed error.
    11.PNG


  • This post is deleted!

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


  • This post is deleted!

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


  • @admin any update on this?


  • @vip trying doing pip install smartapi-python --force-reinstall and run again.


  • @admin also

    Heartbeat sending failed.

    e94e0f24-c985-4f34-b0e3-8394e6b96279-image.png


  • @admin Getting error today as well.

    2021-06-16 13:18:27.514597 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'V232487', 'acctid': 'V232487'}
    Error info: Connection to remote host was lost.
    Connection to remote host was lost.
    2021-06-16 13:18:57.519762 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'V232487', 'acctid': 'V232487'}
    HeartBeat Sending Failed
    2021-06-16 13:19:27.524737 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'V232487', 'acctid': 'V232487'}
    HeartBeat Sending Failed
    2021-06-16 13:19:57.530171 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'V232487', 'acctid': 'V232487'}
    HeartBeat Sending Failed
    2021-06-16 13:20:27.535489 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'V232487', 'acctid': 'V232487'}
    HeartBeat Sending Failed
    2021-06-16 13:20:57.541105 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'V232487', 'acctid': 'V232487'}
    HeartBeat Sending Failed


  • @admin same is happening with me.
    I am getting more 3 errors:

    [WinError 10053] An established connection was aborted by the software in your host machine
    and
    [WinError 10054] An existing connection was forcibly closed by the remote host
    and
    [SSL: SSLV3_ALERT_BAD_RECORD_MAC] sslv3 alert bad record mac (_ssl.c:2633)

    I am passing around 12 to 15 scripts.

    nse_cm|20374&nse_cm|881&nse_cm|1333&nse_cm|4870&nse_cm|1594&nse_cm|2885&nse_cm|2963&nse_cm|21808&nse_cm|3045&nse_cm|3351&nse_cm|3456&nse_cm|3499


  • HI @s4ntosh How many scripts you are passing.


  • @admin Screenshot_10.jpg

    This has happened today at 12:24 again, this time with a different error code