peer dropped the TCP connection without previous WebSocket closing handshake

AkashTawade
whenever i try to run a code for 100 instrument tokens it works perfectly fine. But the same code run on 2850 instruments I get the error above.
please resolve
  • AkashTawade
    take a look at the error occured
  • rakeshr
    @AkashTawade
    Error in above file:
    builtins.KeyError: 'depth'
    Websocket subscription mode,auto change from FULL_MODE to QUOTE Mode,if market depth is zero,so you will receive key error in depth for such instruments.
  • AkashTawade
    Token are set on full mode itself. The code running for like one minute. The code modifying data in .xlsx format for upto one minute perfectly fine. After that the programme throwing these errors.
    FYI all the tasks I needed to perform are under on_ticks function.
  • sujith
    You need to offload your stuff from on_tick to some other thread. Ideally, a user is not supposed to block on_tick. The main thread should always be available to listen to incoming binary data.

    The depth error is because the first tick you receive (after a reconnection) could be in quote mode because default subscription sets the mode to quote. Ideally, you need to check if the mode is full and then only access depth data.
  • AkashTawade
    thank you @sujith I'm using MultiThreading and the code is working perfectly fine.
This discussion has been closed.