Receiving WebSocket connection error randomly every now and then

kontacthimanshu
I am receiving following error message randomly:

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

I am using the threaded WebSocket example. I have modified the infinite loop at the bottom of this example like below. You are checking if WebSocket is connected or not. In the "else" block of the "if" block I am printing an error message "Connection Disconnected!!". This message is also appearing randomly many times. So does that mean the WebSocket connection is breaking too often and is not stable.
while True:
count += 1
if count % 2 == 0:
if kws.is_connected():
pass
else:
logging.critical("### Connection Disconnected!!")
# kws.set_mode(kws.MODE_LTP, tokens)
# else:
# if kws.is_connected():
# logging.info("### Set mode to quote for all tokens")
# kws.set_mode(kws.MODE_QUOTE, tokens)
I have loaded WebSocket example module in its own thread using ThreadPoolExecutor. Do I need to give it lot of threads?
  • rakeshr
    Using ThreadPoolExecutor should be fine until you are blocking any of the callables.
    We need to see complete code, to comment on anything more.
  • kontacthimanshu
    Is it possible to get on Zoom or Skype call to show you complete code?
  • kontacthimanshu
    I will update as much code here as possible today or tomorrow. Please keep the thread open.
Sign In or Register to comment.