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.
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 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
@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.
@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 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.
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.
@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
@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.
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.
@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) ?
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.
This will help development based on that rather changing everything
It will be restricted to maximum of three connections per api_key.
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
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.
We just tried to reproduce the scenario with 3 websocket connections. All three connections are open and getting ticks after 40 min.
In my case, websockets closing down is a frequent thing so I am a bit perplexed.
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.
Thanks. Also, just to understand, would it be possible to release reconnection feature for python client by end of this week ?
We are planning to release it by the weekend.
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
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.
We will release it soon.
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) ?
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)