It looks like you're new here. If you want to get involved, click one of these buttons!
2022-09-08 22:07:18,569 - kiteconnect.ticker - Thread-1 (run) - ERROR - Connection error: 1006 - connection was closed uncleanly (None)
from kiteconnect import KiteConnectfrom kiteconnect import KiteTickerimport timeimport logginglogging.basicConfig(format='%(asctime)s - %(name)s - %(threadName)s - %(levelname)s - %(message)s', level=logging.INFO, handlers=[logging.StreamHandler()])access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'api_key = 'xxxxxxxxxxxxx'kite = KiteConnect(api_key)kite.set_access_token(access_token)my_ticks = def on_ticks(ws, ticks): global my_ticks my_ticks.extend(ticks) # adding multiple elements to the end of the listtokens = def on_connect(ws, response): ws.subscribe(tokens) ws.set_mode(ws.MODE_FULL, tokens)def on_close(ws, code, reason): pass # On connection close stop the event loop. # Reconnection will not happen after executing `ws.stop()` # ws.stop()kws = KiteTicker(api_key, access_token)kws.on_ticks = on_tickskws.on_connect = on_connectkws.on_close = on_closekws.connect(threaded=True)while True: if my_ticks: print(my_ticks[-1]) time.sleep(5)
Running kite ticker, when http connection is lost, I get a log error message:where shall I put try-catch to catch the error 1006 as mentioned above?
so you mean to say that no exception will be generated
I should let the auto-reconnect feature take care of the situation?
should I handle the error log by adding filter to the logger?
ws.stop()i.e force stop the ticker anywhere undesired. Multi-line comment here explains about auto-reconnect mechanism in more detail.