Read normal, abnormal disconnection here https://tools.ietf.org/html/rfc6455#section-7.4
You can see abnormal disconnection when you plug out the LAN for an example. In kite ticker, every WebSocket connection has associated tokens.
1. In case of nor…
https://github.com/zerodhatech/pykiteconnect/blob/master/kiteconnect/ticker.py#L683
resubscribe happens if the previous disconnection was not an abrupt disconnection.
@saurabh3679
kws.connect(threaded=True) runs ticker in a separate thread
That means you ll have to block the main thread in some way.
If you need to process dataframe in a separate thread, you dont need to run ticker in threaded mode. Create a new…
@mapreduce Can you try with bare ticker code without any logic inside?
If you have any blocking script inside on_ticks, please move it to separate thread.
Refer: https://kite.trade/docs/pykiteconnect/v3/#kiteconnect.KiteConnect.cancel_order
https://github.com/zerodhatech/pykiteconnect/blob/master/kiteconnect/connect.py#L348
`pip show version`
https://pypi.org/project/kiteconnect/
Make sure it is 3.7.…
@babansfolio Can you give the platform, kiteconnect version?
Exact code to replicate on our end would help us debug this much faster.
Also,we checked for few very illiquid scrip BANKNIFTY19APR29000PE(9889282) and NIFTY19APR9150CE(11742466), but we g…
@Imran Can you do `pip install https://raw.githubusercontent.com/zerodhatech/python-wheels/master/WHEEL_NAME`
replace WHEEL_NAME with appropriate twisted wheel according to your distribution from here https://github.com/zerodhatech/python-wheels
@neerleo88 This "evidence" you are showing is not helping. The code you had provided is buggy because it was blocking on_tick callback.
Unclean closure of a websocket can happen for several different reasons starting from having a bad network conne…
@neerleo88 Did you try with sample examples provided with pykiteconnect ?https://github.com/zerodhatech/pykiteconnect/blob/master/examples/ticker.py.
No issues here.
@neerleo88 As @rakeshr said you are doing db ops inside ticks functions.
We do not give coding support, but because this query is being repeated multiple times. Here is bare minimum program to delegate such intensive task to another thread.
python…
@tejasvgupta1 All you have to do is to make sure that heavy tasks are not performed in callback handlers.
https://github.com/zerodhatech/pykiteconnect/blob/master/kiteconnect/ticker.py#L130
^ says it will drop connection if you block which cannot e…
@naz
Sorry, single process can only have one reactor
https://github.com/zerodhatech/pykiteconnect/blob/master/kiteconnect/ticker.py#L524
So, even if you try creating multiple threads, it wont. that explains the first issue
But you can easily circu…
work fine here. It will only fail if you have more than 3000 tokens
import logging
from copy import copy
from kiteconnect import KiteConnect, KiteTicker
logging.basicConfig(level=logging.DEBUG)
api_key = ""
access_token = ""
client = KiteConnect(…
https://github.com/zerodhatech/pykiteconnect#websocket-usage
mentions
def on_close(ws, code, reason):
# On connection close stop the main loop
# Reconnection will not happen after executing `ws.stop()`
ws.stop()
so if you remove ws.stop(…
@genesis
Instead of redirecting stdout to file, you could simply write that logic inside your script.
Websocket disconnects can occur due to several problems. But we do have re-connection mechanism to handle such cases.
Speaking of reconnection , p…
@keshav_ not able to reproduce this error on python 3.7
Can you give your exact python version even if it is alpha release?
Also your platform, architecture.
And this
import sys
print sys.maxunicode
Easy way for retrying is by plugging in urllib3 `Retry` into the kiteconnect pool param.
It would something like this
pool_opts = {"max_retries": Retry(...)}
kite_client = KiteConnect(api_key="API_KEY", access_token="TOKEN", pool=pool_opts)
refers t…
@sripal
try now with `pip install kiteconnect==3.7.6`
if you are getting any issues related to twisted failing to build wheels.
download appropriate platform twisted wheel from here https://github.com/zerodhatech/python-wheels
and do `pip install …
For now, do this
`curl https://github.com/zerodhatech/python-wheels/raw/master/Twisted-18.7.0-cp37-cp37m-win_amd64.whl`
`pip install /path/to/where/downloaded --no-cache`
`pip install kiteconnect --upgrade`
@RP3436 Oops. I'd already added 3.7 twisted wheels for windows. Let me do a release on https://github.com/zerodhatech/pykiteconnect. It should work after that.
@rvsw All i m saying is `pip install kiteconnect` should work as expected and you should not be getting any visual C++ required warning.
Can you uninstall kiteconnect completely and try pip install kiteconnect --no-cache?
Paste the stacktrace if yo…
@rvsw I have described it here https://kite.trade/forum/discussion/comment/14205/#Comment_14205
pykiteconnect uses twisted for websocket and that brings all the trouble of compiling twisted for windows platforms. To prevent this, we uploaded twiste…
@Ashok121 Any unhandled exception in your code will result in on_error which in turn calls on_close. But now you added ws.stop inside on_close which will stop the ticker loop instead of the re connection mechanism. If you need the re connection logi…
@ansumanm Can you paste the full code?
There should be some bug in the code. Can you enable debug flag and check for stacktraces ? Any exception occurring in the event loop will result in on_error which will in turn close the connection.
@PREMCHANDGUPTA Can you uninstall the existing kiteconnect?
`pip uninstall kiteconnect`
`pip install kiteconnect --no-cache`
If not working, try this
Assuming PC is 64bit and python 3.6, download
https://github.com/zerodhatech/python-wheels/blob/ma…
@pracas KiteTicker has stop meth. Can you make sure that you're using the latest kiteconnect? https://pypi.org/project/kiteconnect/. Also, the 2nd `kws.connect()` will be an issue because you cant restart the websocket in the same python process.
@TUSH123
I m sure there is an issue with python paths
see for eg
Requirement already satisfied: incremental in ./Twisted-17.1.0/.eggs/incremental-17.5.0-py3.6.egg (17.5.0)
^ says incremental is installed in a relative path
But your twisted is ins…
@TUSH123 Check if the pip3.6 and python3.6 has the same path. So, open up python3.6 shell. try this
>>import incremental
^works?
then do
>>incremental.__file__
make sure incremental is inside /usr/local/lib/python3.6/site-packages/
if n…
@hiwarekar
Installing collected packages: kiteconnect
Running setup.py install for kiteconnect ... done
Could not find .egg-info directory in install record for kiteconnect from https://files.pythonhosted.org/packages/e9/74/5354c5845ae4108329b1…
@hiwarekar
`pip show kiteconnect` should show 3.7.4. Otherwise you are running old version.
Now, if you running old one. Try this
`pip uninstall kiteconnect`
`pip install kiteconnect --no-cache-dir`
@razcads It seems pip is trying to upgrade requests lib and failing. Can you try `pip install requests --upgrade`? Also you should not ideally use sudo, everything should happen inside virtualenv. You can even skip installing dependencies if the env…
@vineet_dhandhania
1. kws.connect is basically a twisted event loop. Here is the "infinite loop" you are looking for. https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/base.py#L1264
2. Are you talking about the comment line on thre…
@girish400 Fine. Changing TypeError to general Exception would do the trick because even datetime.fromtimestamp(1) raises the OSError so does any invalid dates.
@krishnanm2006 Please use pykiteconnect. Or please refer to
https://kite.trade/docs/connect/v3/user/#signing-requests
https://kite.trade/docs/connect/v3/market-quotes/#instruments
@BulkDealAlert Are you saying that you did all the upgrade including python3.6, pip, C++ 14, Builder tools?
Can you post the full traceback logs here if you hitting any error?
Also go through this thread once https://kite.trade/forum/discussion/3910
@Pavan This has something to do with your implementation. I m afraid we don't have anyone with Qt expertise. Closest thing would be the rust client https://github.com/zerodhatech/kiteconnect-rs/blob/master/src/ticker.rs#L342. Would be awesome if som…
@BulkDealAlert
Upgrade your kiteconnect client https://github.com/zerodhatech/pykiteconnect/#installing-the-client as v3 is active now. `pip show kiteconnect` should show 3.7.0. Migrate your code to support v3.
Examples: https://github.com/zerodhat…
@c00kie Did you rule out network issues at your end? Can you once run ticker example from the pykiteconnect repo.
https://github.com/zerodhatech/pykiteconnect/blob/kite3/examples/ticker.py
You can add serializer for json.dumps using `default` param…
@c00kie Dont see any issues here. Few qns. How are you invoking disconnectTicker?
Can you use debug flag on kiteticker and post the logs?
Why do you use pickle serialisation instead of json?
@razcads Please post your ticker code. No, new ticker connection wont trigger on_close. You cant run multiple ticker instances in the same python process.
@razcads I m sure traceback will be printed to stdout for errors like `usage of a variable before assignment`. KiteTicker class also supports a debug flag which further shows you all debug logs including that of twisted.
@Mohit check this sample out for getting ticks in 5 second interval. https://kite.trade/forum/discussion/comment/14144/#Comment_14144
Firstly, remove infinite while loop. Once ticker is closed and ws.stop gets called, you won't be able to resta…
@Ashok121 Sorry cant help you with coding. https://kite.trade/forum/discussion/comment/14144/#Comment_14144 is a solution along the similar lines you overlooked.
Using time.sleep inside on_ticks callback and expecting new tick is wrong.
Also once…
@Ajax Please post the code and kiteconnect version
You can also check these threads
* https://kite.trade/forum/discussion/comment/14185/#Comment_14185
* https://kite.trade/forum/discussion/comment/14117/#Comment_14117
@babansfolio Closing websocket inside for loop is wrong. This is pretty straightforward thing. You can simply compare if datetime is post 3:30, call `ws.close()` inside on_ticks.
@naz
so I am guessing Microsoft Visual C+ 14 compiler version shouldn't be an issue
Nope. Kiteconnect v3 uses twisted behind the scenes for websocket. Issue is twisted wheels are not distributed properly and that brings the microsoft visual C++ co…
@naz
Error clearly says `Microsoft Visual C+ 14.0` is required. Get it with `Microsoft Visual C++ Build Tools`. Check this
Please refer these threads
https://kite.trade/forum/discussion/3645/kiteconnect-installation/p1
https://kite.trade/forum/dis…
@joe
Please double check this
ReactorNotRestartable is self explanatory. You simply cannot restart the ticker in the same process.
Explanation to `stop` and `close` meths are defined in the docstrings here
@joe Please post your code
Here is a sample
import time
start_time = None
first_tick_flag = True
def on_ticks(ws, ticks):
global first_tick_flag , start_time
if first_tick_flag:
first_tick_flag = False
start_time = time.ti…
@joe Well for starters, you can initialise a start_time variable in the first tick and end_time for every ticks, calculate the difference in the end_time and start_time is greater than 5 and proceed with processing the ticks. Using signals inside ev…
@joe
There is a ping loop going on here.
And you are disrupting it with sleeping 5 seconds inside on_ticks which is wrong. Remove sleep and it will work. I m seeing many forum threads which opposes the way websocket client is supposed to work. If y…
@Ashok121
Write that logic with dates inside on_ticks callback
KiteTicker cannot be restarted if it is closed in the same process
Writing an infinite while loop on top of an event loop is wrong
Hope it makes sense
@Ashok121 What purpose does the while loop serve here? Error clearly states that the reactor is not restartable and still you close the ticker on on_ticks and attempts to restart. This clearly defeats the purpose of websocket. If your idea is for pr…
@Ashok121 Check this.
Yup ws.stop() has to happen inside on_close callback. But to trigger on_close callback based on some logic, you need to call ws.close() somewhere right?