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

ragini
ragini edited June 28 in Python client
Hello ,

I'm using three tickers for kite and running in thread

//CODE

thread1 = threading.Thread(target=ticker.initiatKiteTicker, args=["T1", ("NIFTY", ), save])
thread2 = threading.Thread(target=ticker.initiatKiteTicker, args=["T2", ("BANKNIFTY", "FINNIFTY",), save])
thread3 = threading.Thread(target=ticker.initiatKiteTicker, args=["T3", ("SENSEX", "MIDCPNIFTY", "BANKEX", ), save])
# Start threads
thread1.start()
time.sleep(0.5)
thread2.start()
time.sleep(0.5)
thread3.start()
subscribe_to_channel()
# Wait for threads to complete
thread1.join()
thread2.join()
thread3.join()

// onMessage function for onticks
print("TICKER",tick_type, len(ticks))
publish_message(tick_type, ticks) //redis queue
if (SAVE_TICKER and len(ticks)>100):
print(ticks)
..db dave
return

--- i'm adding ticks data to redis queue for further calculations.

// KITE CONNECT CODE

kws.on_ticks = onMessage
kws.on_connect = on_connect
kws.on_close = on_close
kws.on_reconnect = on_reconnect
# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect()


ISSUE : My ticker getting disconnected three of four times in a day with error
ticker:Connection error: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)

if i'm using
kws.connect(threaded=True)
then my ticker getting disconnected in minutes and connecting again

Please provide me solution what do i need to change in my implementation.


Thanks.
  • ragini
    @rakeshr can you please suggest the solution.
  • rakeshr
    I'm using three tickers for kite and running in thread
    No, you don't need to initiate ticker for each instrument. You can subscribe to a list of instruments in a single ticker up to 3000.
    My ticker getting disconnected three of four times in a day with error
    ticker:Connection error: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
    This error mostly occurs, when the main ticker `on_ticks` is blocked operating when receiving new ticks.
    This python project goes through in detail about tick async queue and insert.
Sign In or Register to comment.