migration to pykiteconnect 3.7.0

pracas
pracas edited February 2018 in Python client
Hi,

I'm trying the websocket usage example and get the following error

WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
].

any ideas what could be wrong?
  • rakeshr
    Hi @pracas,
    Please make sure you are using the latest release.
    pip install kiteconnect --upgrade --pre
  • pracas
    Hi,

    Been banging my head on this for a week now... i've uninstalled and reinstalled in all possible configurations and get the same error. I've tried the above method and get a confirmation that "Successfully installed kiteconnect-3.7.0b3"

    ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using. ].


    code used is a simple print

    from kiteconnect import KiteTicker

    # Initialise
    kws = KiteTicker("your_api_key", "your_access_token")

    def on_ticks(ws, ticks):
    print(ticks)

    def on_connect(ws, response):
    # Callback on successful connect.
    # Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
    ws.subscribe([738561, 5633])

    # Set RELIANCE to tick in `full` mode.
    ws.set_mode(ws.MODE_FULL, [738561])

    # Assign the callbacks.
    kws.on_ticks = on_ticks
    kws.on_connect = on_connect

    # Infinite loop on the main thread. Nothing after this will run.
    # You have to use the pre-defined callbacks to manage subscriptions.
    kws.connect()
  • pracas
    reposting error message as unable to edit previous post

    ERROR:kiteconnect.ticker:Try reconnecting. Retry attempt count: 1
    ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): /<"class 'twisted.internet.error.ConnectionAborted'/>: Connection was aborted locally, using.
    ].
  • sujith
    You can check out this thread.
  • pracas
    @sujith Nope... doesn't help... tried that as well... how long before the previous version of kite is phased out? i need to move some websocket applications and getting worried.
  • rakeshr
    Hi @pracas ,
    Can you paste you code here?
  • pracas
    @rakeshr Here is the code... its the example from github with the logging removed and a few print statements added. none of the print statements get executed.

    from kiteconnect import KiteTicker
    # Initialise
    kws = KiteTicker("api-key", "accesstoken")

    def on_ticks(ws, ticks):
    # Callback to receive ticks.
    print("here3")
    print(ticks)

    def on_connect(ws, response):
    # Callback on successful connect.
    # Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
    print("here0")
    ws.subscribe([738561, 5633])
    print("here1")

    # Set RELIANCE to tick in `full` mode.
    ws.set_mode(ws.MODE_FULL, [738561])
    print("here2")

    # Assign the callbacks.
    kws.on_ticks = on_ticks
    kws.on_connect = on_connect

    # Infinite loop on the main thread. Nothing after this will run.
    # You have to use the pre-defined callbacks to manage subscriptions.
    kws.connect()
  • sujith
    Can you do
    pip show kiteconnect
    and check which version of the library you are using?
  • Guhan
    Guhan edited February 2018
    @sujith actually I am getting same error for my second websocket connection. But first one is running fine.
  • pracas
    Today i took a brand new laptop, installed ubuntu 16.04 64-bit, anaconda with python3.6 and tried this again... and got the exact same error. wondering if this could be related to my account - DP3211 / Are there any dummy account ids for testing?
  • Guhan
    I do not think there is any dummy account or sandbox environment for testing. I am facing the same issue. Websocket connect that started before 09:05 is running fine but connection that started after 10:00 is not working. Both have same code, only the Database name is different
  • Guhan
    @pracas I tried and gave up running Kite API on Ubuntu, so using windows now
  • sujith
    @pracas,
    There have been multiple beta releases to this channel. Hence I am asking what is the exact kiteconnect version you are using? You need to be on the latest version of kiteconnect.
    If not then, you need to do
    pip install kiteconnect --upgrade --pre
  • sujith
    @Guhan,
    The platform shouldn't be a problem. It will work on all the OS.
  • Guhan
    @sujith Oh K then it has to be my mistake, I will retry and let you know
  • pracas
    @sujith kiteconnect 3.7.0b3 thats what got installed on both the systems when i ran
    In addition today i tried uninstalling and reinstalling, i get the same error with 3.7.0b4 aswell.
    Additional Dependecy version list as follows. I think the problem m

    requests 2.18.4
    six 1.11.0
    autobahn 17.10.1
    Twisted 17.9.0
    pyOpenSSL 17.5.0
    service-identity 17.0.0
    enum34
    python-dateutil 2.6.1
    chardet 3.0.4
    certifi 2018.1.18
    idna 2.6
    urllib3 1.22
    txaio 2.8.2
    incremental 17.5.0
    constantly 15.1.0
    Automat 0.6.0
    zope.interface 4.4.3
    hyperlink 17.3.1
    cryptography 2.1.4
    attrs 17.4.0
    pyasn1 0.4.2
    pyasn1-modules 0.2.1
    setuptools 38.5.1
    cffi 1.11.4
    asn1crypto 0.24.0
    pycparser 2.18
    pip install kiteconnect --upgrade --pre
  • pracas
    Heres a screenshot of the error

  • Vivek
    Vivek edited February 2018
    @pracas Can you please paste full logs? Check if you have an log like this
    2018-02-07 11:15:36,673 - root - ERROR - closed connection on close: 1006 connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    If yes then its because of invalid access token.
  • pracas
    @Vivek, thats the full log that gets printed in the terminal. any other suggested locations to dig for other log files that may help? I'm using Anaconda on ubuntu16.04... will try installing this on a third system today.
  • pracas
    Tried installing on the only windows 7 system i have and installation fails when installing the twisted package... any help anyone on getting this sorted linux?
  • Guhan
    @pracas, to install twisted in you need latest visual C++ build, i think it will be mentioned in twisted installation error message
  • pracas
    @guhan... yes.. but i figured getting it running in windows won't help as finally i want to run it in linux... in linux everything installs fine.. however the error persists (refer to the first post)
  • Guhan
    @pracas,
    oh k, I am not a expert in programming and all, but from my experience of trial and error, the error you have mentioned occurs if there is some runtime or logical error in your code, for example I got this error when database name was wrong, also due to column mismatch etc..

    FYI I am running my strategy in Linux 16.04, python 2.7(that comes with linux not anaconda)
  • pracas
    @vivek @sujith any help / pointers to look at?
  • ramatius
    Pls see if your firewall (or some network config or non-root access issue) is blocking the socket connection...
  • sujith
    @pracas,
    Can you check installing the client section here?
  • pracas
    @ramatius ... Well tried running as root... same error as well

    @sujith yup.. installed everything like there multiple times....

    today as a trial i installed this on my remote server and get a new error
    "Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))"

    i hope access token refers to request_token returned in the url (wherever access_token is mentioned) kindly correct me if i'm wrong.

    The only thing left seems to be if someone @zerodha can check if this is something to do with my developer credentials...
  • sujith
    @pracas,
    The above error means you are sending invalid access token.
    A request token is different from access token. Please go through documentation here.
  • pracas
    @sujith Thanks a ton! that resolves everything.... Apologies for all the inconvenience caused due to my overlooking that part of the manual
Sign In or Register to comment.