reconnection after on_error

viveshar
I have added the following to my code to handle errors:
def on_error(ws,error):
print("on_error in websockets::",error)
ws.close()
ws.reconnect()

But whenever i am getting any error, i am not getting the connection back. May I know what's the issue here.
  • Vivek
    Vivek edited April 2017
    @viveshar Can you please try our new Pykiteconnect version which has the auto reconnect feature? Here is the link to get started - https://kite.trade/forum/discussion/comment/5804/#Comment_5804 and https://kite.trade/forum/discussion/comment/5761/#Comment_5761
  • viveshar
    I am getting the following error - ERROR:websocket:error from callback >: maximum recursion depth exceeded

    Any idea whats the issue here.

    Given below is a part of my code.
    def on_close(ws):
    ws.reconnect()

    def on_error(ws,error):
    print("on_error in websockets::",error)
    ws.connect()

    def on_disconnect(ws):
    ws.connect()


    def on_connect(ws):

    ws.subscribe(instrumenttokenlist)
    ws.set_mode(ws.MODE_FULL,instrumenttokenlist)


    kws.on_tick = on_tick
    kws.on_connect = on_connect
    kws.on_close = on_close
    kws.on_error = on_error
    kws.on_disconnect = on_disconnect

    kws.enable_reconnect(reconnect_interval=5, reconnect_tries=50)

    kws.connect(disable_ssl_verification=True)

  • naz
    Hi Viveshar,
    Are you using python pandas for processing? In case it helps, I got this error while using python pandas for processing tick data.
  • viveshar
    Hi naz,

    yes I am using python pandas for processing. Were you able to resolve this issue ?
  • naz
    In my case, this error came when there were duplicate entries on one of the axes of pandas (duplicate instrument token etc.) and I was trying to use df.fillna( ) or was trying to change the dimension of the object.
    Removing the duplicate index/column might solve your issue.
Sign In or Register to comment.