Websocket disconnects if connected before 9:15 AM

RDC232
Hello,

I have connected the websocket at 9:14 AM. But it got disconnected.
When I connect at 9:15 it works. Because of this I missed some ticks. I am attaching the code.

In the below code, the sleeps till 9:14 AM and then perform the connection with websocket. After connection It subscribe the instrument tokens which i have in a csv file present at path1.
At 9:15 it gives the error 1006.
The same code executes correctly without any error if I execute the code at or after 9:15 AM.

def on_connect(ws, response):
global path1, path2
print('Code Started')
token=pd.read_csv(path1)
instrument_tokens=list(token['instrument_token'])
ws.subscribe(instrument_tokens)
# Set tick in `full` mode.
ws.set_mode(ws.MODE_FULL,instrument_tokens)

m=(9-datetime.now().hour)*3600+(14-datetime.now().minute)*60-datetime.now().second
if m>0:
time.sleep(m)

kws = KiteTicker(api, access_token)
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close
kws.connect()
Sign In or Register to comment.