Hi, I am running a strategy that is time based . What I am facing is when time exceed to the exceed time, I unsubscribe all the token that i subscribe initially and then use ws.stop() like this for tick in ticks: print(tick) strategy(stock_initial_ref[tick['instrument_token']]) if nse_end_time >= time(10,0,0).strftime('%H:%M:%S'): ws.unsubscribe(token_list) ws.stop() But when exit condition reach it is giving me a error Connection error: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake) ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake) I want to close the socket gracefully and exit from the code smoothly without any error.
ws.close()
, and gracefully exit the code accordingly.