PyKiteConnect - Reconnecting to Websocket Cleanly without Process Restart

Hi Folks

How can one cleanly reconnect to websocket? Basically my usecase is start at 9AM and close websocket at 4 PM. I am aware exiting the process and restarting next day will work but for some other reason i don't want to follow this approach. Is there a way to pause/restart websocket connection in same process?

I cannot call kite_web_socket.stop() as it stops the reactor and it can not be restarted within a process ever again (same as in
If i call kite_web_socket.close() at 4 PM and then retry to connect next day for some reason it never actually connects back and just remains with kite_web_socket.is_connected() == False even after multiple attempts.
If i don't call kite_web_socket.close() then it usually works for next day but then abruptly stops on some days (probably due to token expiry?) or something ?

On the similar note, is it also possible to connect to two different kite websocket (assuming separate api's) from same process?
  • rakeshr
    Reconnect won't work, as we flush all sessions(APIs and WebSocket) around 07:30 AM every day. This thread explains more.
  • noobjethalal
    noobjethalal edited February 2023
    @rakeshr I am actually establishing a new connection at 9AM too (but on the same old process that was created previous day only), but it doesn't seem to connect remains on state kite_web_socket.is_connected() == False. I have put debug=true and will try to identify if i get any more logs today/tomorrow.
Sign In or Register to comment.