" kiteconnect.ticker:connection error: 1006 - connection was closed uncleanly (I dropped the websocket tcp connection: 'int' object is not iterable) " I am getting this error as soon as I start the web socket.. The same code was working very well on Friday, I have just increased the instrument count for subscription from 5 to 30. I am sure that should not be a problem. Also I debugged to see whether I had any issues with my code in on_ticks() where I handle the received tick_data but the control won't get there at all. Even before getting my very first tick data, on_close() is called and websocket is closed with above mentioned error.
Please respond as soon as possible since I have already lost a day.
You can get connection errors at times, that's why you need to have error handling code (try, except) for when this happens. If it cannot be handled automatically, you should set up an alert system like an automatic call to your phone so that you can respond manually
@rishiswethan I agree on the importance of error handling code. I do have a simple logging and notifying code as my error handling now.
But what is the solution to this problem?? I am not able to continue with my work..
Looking at the other similar threads on the issue, now I am guessing, whatever I am doing in on_tick() is heavy for websocket and it is blocking the main thread...
Once I modify my application to handle on_tick() operations in a separate thread, I will come back with my results..
@chethan_kumar i guess one of your scrip might be in RMS limits ... i am not completely sure... i would recommend you run your codes by reading data types of WS as it comes in .. you might get some clarity whats messing up your codes.
i guess one of your scrip might be in RMS limits ... i am not completely sure... i would recommend you run your codes by reading data types of WS as it comes in .. you might get some clarity whats messing @chethan_kumar
@chethan_kumar, You seem to be blocking the main thread. The idea is to keep the websocket listener in one thread whose task is only receiving the data and nothing else. Use some slave threads to do your operations. This is a very common mistake everyone does. The issues magnitude increases as you listen to more ticks. There are many threads about this on the forum, do a search and take a look at them.
@sujith I tried removing the complete burden of main thread by handling the tick data obtained in on_ticks() in a separate thread.
But I got the same error.
Just to clear things completely I removed everything I'm doing inside on_ticks() and kept only the logger which just logs the received thread on to console.
Even then I got the same error.
@sujith websocket closing immediately after connecting was bcoz there was an exception happening in my code.
But oddly, I didn't get the exception in the console, only the connection used to drop with the above mentioned error message. I couldn't figure out why it didn't log the exception even with try-except present.
Also can u please point me to a link/example containing efficient usage of KiteTicker in a multi threaded program!??
Because what I have written now makes the connection to close after about 30-40second run. I know the connection is closing after 30-40 seconds because I am starting another thread inside on_tick() to handle the data and that thread is doing a bit heavy tasks such as DB connection and continuously updating a data structure in the application with latest data. Or may be I am missing something.
An example with proper usage of KiteTicker with multiple threads running simultaneously would really help.
But what is the solution to this problem?? I am not able to continue with my work..
Looking at the other similar threads on the issue, now I am guessing, whatever I am doing in on_tick() is heavy for websocket and it is blocking the main thread...
Once I modify my application to handle on_tick() operations in a separate thread, I will come back with my results..
I hope it will solve the issue..
i guess one of your scrip might be in RMS limits ... i am not completely sure... i would recommend you run your codes by reading data types of WS as it comes in .. you might get some clarity whats messing up your codes.
@chethan_kumar
You seem to be blocking the main thread. The idea is to keep the websocket listener in one thread whose task is only receiving the data and nothing else. Use some slave threads to do your operations. This is a very common mistake everyone does. The issues magnitude increases as you listen to more ticks.
There are many threads about this on the forum, do a search and take a look at them.
But I got the same error.
Just to clear things completely I removed everything I'm doing inside on_ticks() and kept only the logger which just logs the received thread on to console.
Even then I got the same error.
I am not getting how to solve..
Pls help..
But oddly, I didn't get the exception in the console, only the connection used to drop with the above mentioned error message. I couldn't figure out why it didn't log the exception even with try-except present.
Also can u please point me to a link/example containing efficient usage of KiteTicker in a multi threaded program!??
Because what I have written now makes the connection to close after about 30-40second run. I know the connection is closing after 30-40 seconds because I am starting another thread inside on_tick() to handle the data and that thread is doing a bit heavy tasks such as DB connection and continuously updating a data structure in the application with latest data. Or may be I am missing something.
An example with proper usage of KiteTicker with multiple threads running simultaneously would really help.