Daily websocket disconnection anytime between 10:00 am to 11:00am

rajtk
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
Tagged:
  • sujith
    Hi @rajtk,
    You can use reconnection feature.
    Check out this thread for solution.
  • pinkpanther
    @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
  • sujith
    @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.
  • rajtk
    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
  • rajtk
    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()

    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)
  • sujith
    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.
  • rajtk
    thanks, will do it as advised.
This discussion has been closed.