I noticed one thing when there is a connection timeout the the whole web-socket thread seems to block my other threads. I have started the websocket with on_connect ->threaded= True. Everything goes fine and I don't block the ticks. I just copy the data onto the queue. When there is a drop in the connection , there seems to be a timeout and after a while the websocket resumes and everything is fine. During this timeout detection phase ( default is 30s) my whole program just stops ( Does not happen always , only for certain network conditions - not able to tell which network issue causes a timeout). Has anyone faced a similar issue? Is the blocking happening from some lower layer?
To mitigate this I am thinking of making the timeout as maybe 5 or 10s
I noticed one thing when there is a connection timeout the whole web-socket thread seems to block my other threads.
By other thread, you mean another ticker thread from the main thread, right? In that, if the main thread is blocked/disconnected, other thread originated from the main thread will be disconnected too. Can you paste the complete error stack trace? That should give more info.
Nope , not another ticker thread. Its just my main program where I am doing some calculation. There is no error or anything as such. Its just that during the reconnection phase my main program is getting blocked for those 30s.
Eg:
# call backs are assigned
Main program starts .. .. kws.connect(threaded =True) .. .. while(some_condition): # have a loop for doing some periodic calculations .. ..[ blocking happens inside here during reconnection/timeout] .. .. end of while loop .. kws.unsubscribe() kws.close()
After the timeout the while loop resumes. and the websocket in the background tries to establish a reconnection I even tested by not doing anything inside the while loop -> just a print statement. still it gets blocked
Can you paste the complete error stack trace? That should give more info.
Eg:
# call backs are assigned
Main program starts
..
..
kws.connect(threaded =True)
..
..
while(some_condition): # have a loop for doing some periodic calculations
..
..[ blocking happens inside here during reconnection/timeout]
..
..
end of while loop
..
kws.unsubscribe()
kws.close()
After the timeout the while loop resumes. and the websocket in the background tries to establish a reconnection
I even tested by not doing anything inside the while loop -> just a print statement. still it gets blocked
any idea what can cause such a thing