Number of Websocket Connection Limit

Shabeershah2002
Is there any limit set for number of websocket can be connected ?, as today it seems only 2 is working and 3rd one does not give any output .
  • sujith
    Hi @Shabeershah2002,
    There is no limit on number of connections you can create right now. But we will be limiting soon.
    As of now, opening three websocket connection won't be an issue.
  • Shabeershah2002
    If it is going to limit, can you tell us what could be possible numbers of sockets as maximum ?
    This will help development based on that rather changing everything
  • sujith
    Hi @Shabeershah2002,
    It will be restricted to maximum of three connections per api_key.
  • pranksterguru
    @sujith i have explained you guys earlier.. i dont think the ticker streaming will work efficiently with just 3 sockets
    you have maximum of 200 scripts and 3 sockets limitation.. so, that makes around 70 scripts per one socket..

    when i tested , the performance of socket is majorly impacted if we have more than 10 scripts in it

    can you do a performance testing of sockets before coming up with a plan of reducing it to 3? i have even seen securities not getting price ticker for 2 minutes if i have more than 50 instruments for a socket

  • Shabeershah2002
    I guess it could be 200 per socket so total can be 600
  • sujith
    @pranksterguru,
    We tested for 60+ liquid scrips and it works fine. The same websockets is being used by all 1.9 Lakh client base and we do allow them to add 20 scrips in each marketwatch.

    @Shabeershah2002,
    Yes, you can subscribe up to 600 scrips at a time.
  • naz
    @sujith while connecting three websocket connections, two out of three connections die -off after first 15-30 min and one remains alive. Is it the intended behavior ??
  • sujith
    @naz,
    We just tried to reproduce the scenario with 3 websocket connections. All three connections are open and getting ticks after 40 min.
  • naz
    @sujith Can you please share as to how many symbols/stocks did you take with each of the 3 websockets while testing. Can you please test with 200 symbols/stocks per socket and 3 sockets.
    In my case, websockets closing down is a frequent thing so I am a bit perplexed.
  • sujith
    Hi @naz,
    We tried for 120 symbols and after 30 min all the three connections were intact. I am not sure why it is happening in your case. I think once we release reconnection for python client you can use it.
  • naz
    @sujith
    Thanks. Also, just to understand, would it be possible to release reconnection feature for python client by end of this week ?
  • sujith
    @naz,
    We are planning to release it by the weekend.
  • naz
    @sujith : that's great. Look forward.
  • naz
    naz edited April 2017
    @sujith : I took a log of error while 2 of the 3 websockets dying down automatically. Below is the error signal which seems to indicate that server is closing future connections if there is already one connection in place. First websocket is still running succesfully.

    Can you please advise:

    2017-04-21 14:36:03 DataRealtimeZerodha.on_connect: successfully connected to websocket
    2017-04-21 14:36:03 DataRealtimeZerodha.on_connect: successfully connected to websocket
    2017-04-21 14:36:03 DataRealtimeZerodha.on_connect: successfully connected to websocket
    2017-04-21 14:36:43,083 ERROR 2017-04-21 14:36:43 on_error callback called: [WinError 10054] An existing connection was forcibly closed by the remote host
    2017-04-21 14:39:03,831 ERROR 2017-04-21 14:39:03 on_error callback called: [WinError 10054] An existing connection was forcibly closed by the remote host





  • naz
    @sujith : Hi Sujith,
    1) did you get a chance to look at the error.
    2) Also, didn't see any update on python client reconnect feature over the weekend. Any update on the same.
  • sujith
    @naz,
    1) did you get a chance to look at the error.
    The above error is too generic, it can happen because of a lot of reasons. Maybe network interruption, congestion etc. Hope reconnection will help you to overcome this.
    2) Also, didn't see any update on python client reconnect feature over the weekend. Any update on the same.
    Apologies, We are working on some major deployments for Kite Web, we thought it will be a couple of hours of work but unfortunately there are many dependencies and scenarios that have to be handled.
    We will release it soon.
  • naz
    @sujith : is there a temporary solution. I just feel it is a quite a waste of time to restart the whole program manually whenever disconnection happens (which is happening quite frequently for a lot of us on python client).

    I tried looking at the documentation of python websocket client- have few queries below ( i am using multi-threading for running 3 websockets in parallel, by passing threaded=True parameter to ws.connect() function ):

    In the current python websocket implementation, when the websocket gets disconnected, it calls on_close (please correct me).
    a) In the on_close() call-back, should we call ws.reconnect() or ws.connect() ??

    b) what is the difference between calling the above two (implementation wise) and which one should be preferred over other ?

    c) in ws.reconnect() method, there is no option of running it as a separate thread while in ws.connect, there is an option of passing "threaded = True". Does it mean that ws.reconnect will block everything else ?

    d) and after calling ws.reconnect ()or ws.connect (), would we need to subscribe to tokens again ( I am assuming not) ?



  • Vivek
    @naz @pranksterguru @Shabeershah2002 Here is a beta version of PyKiteconnect with auto reconnect feature - https://github.com/rainmattertech/pykiteconnect/tree/reconnection

    Only change you need to make to your code will be enabling auto reconnect (its not enabled default)

    kws.enable_reconnect(reconnect_interval=5, reconnect_tries=50)
Sign In or Register to comment.