reconnect to WebSocket on lost connection

SAPANKHUNTIA
Hi traders,

I lost the internet connection and this error showed up

ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (None)
ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (None)

how to reconnect in this type of instances.

Thank you.
  • sujith
    You don't have to do it. pykiteconnect has the option to reconnect and it maintains the subscriptions for you.
    You just need to enable it. You can know more here.
  • SAPANKHUNTIA
    SAPANKHUNTIA edited March 2021
    Hi @sujith.

    It will be very helpful if you kindly suggest how to do it.
    Do I need to call the __init__ function and put the variables as my requirement or there is any other way

    Thank you.
  • rakeshr
    Do I need to call the __init__ function and put the variables as my requirement or there is any other way
    __init__ is KiteTicker class initialization. So, you need to set reconnect=True during class initialization.
    kws = KiteTicker("api_key","access_token", reconnect=True)
This discussion has been closed.