What is the kiteticker equivalent for kws.enable_reconnect(reconnect_interval=5, reconnect_tries=50)?
In document somewhere i read, that auto reconnect is enabled by default. Even then connection is getting closed sometimes.
If we want to reconnect explicitly the connection from client side which is the correct way to do it (say may be after a network issue or uptime fluctuation.)?
Can we call kws.connect(threaded=True)? Tried , but getting Reactor Not Restrtable error.
Well. That is already mentioned in help(kws) documentation.
But even after having auto reconnect logic inbuilt, your auto reconnect system is failing at times. So, what I intend to know is also about Manual reconnect when auto reconnect fails.
A simple issue replication can be done as below:
Step 1: Start websocket with threaded=True and debug=True.
Step 2: Plug out the LAN connection or stop the wifi connection manually.. Then see, that the websocket connection gets closed.
DEBUG:kiteconnect.ticker:pong => DEBUG:kiteconnect.ticker:ping => DEBUG:kiteconnect.ticker:last ping was 2.50200009346 seconds back. DEBUG:kiteconnect.ticker:last pong was 2.33599996567 seconds back. DEBUG:kiteconnect.ticker:pong => DEBUG:kiteconnect.ticker:ping => DEBUG:kiteconnect.ticker:last ping was 2.50300002098 seconds back. DEBUG:kiteconnect.ticker:ping => DEBUG:kiteconnect.ticker:last ping was 2.5039999485 seconds back. DEBUG:kiteconnect.ticker:ping => DEBUG:kiteconnect.ticker:last ping was 2.5039999485 seconds back. DEBUG:kiteconnect.ticker:Last pong was 7.50699996948 seconds ago. So dropping connection to reconnect. 2018-04-16 18:31:46+0530 [-] dropping connection to peer tcp4:13.127.123.140:443 with abort=True: None ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (None) ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (None) 2018-04-16 18:31:46+0530 [-] will retry in 2 seconds 2018-04-16 18:31:46+0530 [-] Stopping factory 2018-04-16 18:31:46+0530 [-] Main loop terminated.
Step 3: Now crosscheck using is_connected() that the connection is indeed closed.
In [42]: kws.is_connected() Out[42]: 2018-04-16 18:32:53+0530 [-] False
Step 4: Now start a new connection:
In [43]: kws.connect(threaded=True) 2018-04-16 18:33:08+0530 [-] Starting factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x0000000009091860> DEBUG:kiteconnect.ticker:Start WebSocket connection. 2018-04-16 18:33:08+0530 [-] 2018-04-16 18:33:08+0530 [-] Exception in thread Thread-4556: 2018-04-16 18:33:08+0530 [-] Traceback (most recent call last): 2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\threading.py", line 801, in __bootstrap_inner 2018-04-16 18:33:08+0530 [-] self.run() In [442018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\threading.py", line 754, in run ]: 2018-04-16 18:33:08+0530 [-] self.__target(*self.__args, **self.__kwargs) 2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\site-packages\twisted\internet\base.py", line 1260, in run 2018-04-16 18:33:08+0530 [-] self.startRunning(installSignalHandlers=installSignalHandlers) 2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\site-packages\twisted\internet\base.py", line 1240, in startRunning 2018-04-16 18:33:08+0530 [-] ReactorBase.startRunning(self) 2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\site-packages\twisted\internet\base.py", line 748, in startRunning 2018-04-16 18:33:08+0530 [-] raise error.ReactorNotRestartable() 2018-04-16 18:33:08+0530 [-] ReactorNotRestartable 2018-04-16 18:33:08+0530 [-]
We get this error of ReactorNotRestartable. In earlier version, i used to check every 5 mins that a tick is received or not. If he tick is not received and connection is also closed, i used to restart the connection and it used to work.
Now in new version, you are not allowing to restart connection. Whats the solution to this problem. I am looking for a way to ensure that the reconnect happens even if the reconnect or connect instruction is sent from client side(specifically on wakeup from a network issue, manual pause of internet connection, etc).
@zartimus Perfect diagnosis. Kept it running in commodities whole day today. And worked perfect. Also able to manually connect after network disruptions. I kept wifi off for over 3 hours and then attempted a reconnect manually. It worked. Thats all that i wanted. Thanks.
@Shaha , I don't know if you are still there. I am having same issues. Due to some unknown reasons, ticks are stopped but is_connected() is always true so it never goes in auto reconnection... Can you help me to reconnect manually?
You enable reconnect here in the new pykiteconnect.
But even after having auto reconnect logic inbuilt, your auto reconnect system is failing at times. So, what I intend to know is also about Manual reconnect when auto reconnect fails.
A simple issue replication can be done as below:
Step 1:
Start websocket with threaded=True and debug=True.
Step 2:
Plug out the LAN connection or stop the wifi connection manually..
Then see, that the websocket connection gets closed. Step 3: Now crosscheck using is_connected() that the connection is indeed closed. Step 4:
Now start a new connection:
In [43]: kws.connect(threaded=True)
2018-04-16 18:33:08+0530 [-] Starting factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x0000000009091860>
DEBUG:kiteconnect.ticker:Start WebSocket connection.
2018-04-16 18:33:08+0530 [-]
2018-04-16 18:33:08+0530 [-] Exception in thread Thread-4556:
2018-04-16 18:33:08+0530 [-] Traceback (most recent call last):
2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\threading.py", line 801, in __bootstrap_inner
2018-04-16 18:33:08+0530 [-] self.run()
In [442018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\threading.py", line 754, in run
]: 2018-04-16 18:33:08+0530 [-] self.__target(*self.__args, **self.__kwargs)
2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\site-packages\twisted\internet\base.py", line 1260, in run
2018-04-16 18:33:08+0530 [-] self.startRunning(installSignalHandlers=installSignalHandlers)
2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\site-packages\twisted\internet\base.py", line 1240, in startRunning
2018-04-16 18:33:08+0530 [-] ReactorBase.startRunning(self)
2018-04-16 18:33:08+0530 [-] File "C:\ProgramData\Anaconda2\lib\site-packages\twisted\internet\base.py", line 748, in startRunning
2018-04-16 18:33:08+0530 [-] raise error.ReactorNotRestartable()
2018-04-16 18:33:08+0530 [-] ReactorNotRestartable
2018-04-16 18:33:08+0530 [-]
We get this error of ReactorNotRestartable.
In earlier version, i used to check every 5 mins that a tick is received or not. If he tick is not received and connection is also closed, i used to restart the connection and it used to work.
Now in new version, you are not allowing to restart connection. Whats the solution to this problem. I am looking for a way to ensure that the reconnect happens even if the reconnect or connect instruction is sent from client side(specifically on wakeup from a network issue, manual pause of internet connection, etc).
You are stopping the reactor on_close callback right? Remove this callback and the re-connection logic will kick in.
Perfect diagnosis. Kept it running in commodities whole day today. And worked perfect. Also able to manually connect after network disruptions. I kept wifi off for over 3 hours and then attempted a reconnect manually. It worked. Thats all that i wanted. Thanks.
Are u from zerodha support or an user?
Your query is answered here.