I have recently started running an example code for Websocket streaming and recording ticks in a database for only one instrument (Nifty 50 index) on python client (version 3.7.7). The code is multithreaded and kite.connect() does not block the main thread (I record ticks in the database in a separate thread). However, every day there is a problem wherein, I get the following error while the code is running
Connection error: 1006 - connection was closed uncleanly (None)
The interesting bit is that this happens generally after 12:30 pm (one day it happened after 1 pm, another day after 12:50 pm and today at 12:23 pm). Post the connection break, it generally reconnects after 3-5 seconds, and then records ticks for about a minute but after that, there are no ticks recorded for almost the next 10 minutes (another consistent and interesting bit!), post which the same error happens again, and the cycle continues.
Why does this happen every day after 12:30 pm that too in 10 min intervals? I am using multithreading and recording ticks for only one instrument hence I do not believe that might be the issue. Please help resolve this issue at the earliest.
P.S. I am using python3 on a MacOS 2015 version (the database I record to is psql based and stored locally). I use a new access token everyday before market opens.