I am sure there was no issues with my internet connection during this time. Is this a bug ? Or I am the only one facing this issue ? There are no error generated, the feed just stops. please advise
@rajtk even I am also this.. what client are you using? Also the reconnection solution is a workaround,if my processor takes a certain tick to process more than the reconnection time,then done!!!! it reconnects again , also in certain cases it reconnects but ticks donot arrive
@pinkpanther, You must do all your IO operations on a worker thread and not on the main thread. You should never block the thread which is receiving ticks. I think that will solve your issue.
Thanks Sujith and Pinkpanther. I am using python and there are no major IO operations other than adding a timestamp to the incoming tick and diverting the ticks received to mongodb. I will review the reconnection feature. Thanks
Sujith : Are you suggesting I include this as part of my code to help resolve it ? currently I have only on_tick and on_connect in my code. Please advise
def on_close(ws): ws.reconnect()
def on_error(ws,error): print("on_error in websockets::",error) ws.connect()
Hi @rajtk,
You can create new thread inside onTick and inside that thread write to DB and attach timestamp. Writing to DB is an expensive operation. You might miss some ticks if you block the thread on which you are receiving ticks.
You can use reconnection feature.
Check out this thread for solution.
Also the reconnection solution is a workaround,if my processor takes a certain tick to process more than the reconnection time,then done!!!! it reconnects again , also in certain cases it reconnects but ticks donot arrive
You must do all your IO operations on a worker thread and not on the main thread. You should never block the thread which is receiving ticks.
I think that will solve your issue.
Thanks
def on_close(ws):
ws.reconnect()
def on_error(ws,error):
print("on_error in websockets::",error)
ws.connect()
def on_disconnect(ws):
ws.connect()
def on_connect(ws):
ws.subscribe(instrumenttokenlist)
ws.set_mode(ws.MODE_FULL,instrumenttokenlist)
kws.on_tick = on_tick
kws.on_connect = on_connect
kws.on_close = on_close
kws.on_error = on_error
kws.on_disconnect = on_disconnect
kws.enable_reconnect(reconnect_interval=5, reconnect_tries=50)
kws.connect(disable_ssl_verification=True)
You can create new thread inside onTick and inside that thread write to DB and attach timestamp. Writing to DB is an expensive operation. You might miss some ticks if you block the thread on which you are receiving ticks.