WebSocket connection errors using KiteTicker

tooringanalytics
I installed the latest python kiteconnect client with

pip install kiteconnect --upgrade --pre

I am using Python 3.6.1. I tried fetching ticks using the following script:


#!/usr/bin/env python
import logging

from kiteconnect import KiteConnect
from kiteconnect import KiteTicker


logging.basicConfig(level=logging.DEBUG)


api_key = 'XXXXXXXXXXXXXX'
kite = KiteConnect(api_key=api_key)
# login
login_url = kite.login_url()
print(login_url)
# ...log in from the webbrowser and...
public_token = input('2. Now enter the public token: ')
# replace with actual user id
user_id = 'XY1234'
kws = KiteTicker(
api_key,
public_token,
user_id,
)


# Ticks callback
def on_ticks(ws, ticks):
# Callback for tick reception.
print(ticks)


# Connect callback
def on_connect(ws, response):
# Callback for successful connection.
# Subscribe to a list of instrument_tokens
# (RELIANCE:BSE and INFOSYS:BSE here).
tokens = [
153683204,
153653508,
]
ws.subscribe(tokens)
# Set all symbols to tick in `full` mode.
ws.set_mode(ws.MODE_FULL, tokens)
print('Connected!')


kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.connect()
However, I get the following errors:

ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
].
ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
].
ERROR:kiteconnect.ticker:Try reconnecting. Retry attempt count: 1
ERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
].
ERROR:kiteconnect.ticker:Try reconnecting. Retry attempt count: 2

A similar script for the older version of pykiteconnect used to work. What could be the problem here?
  • vineet_dhandhania
    vineet_dhandhania edited June 2018
    This is wrong:
    kws = KiteTicker(
    api_key,
    public_token,
    user_id,
    )
    It should be like this:
    kws = KiteTicker(api_key="api_key", access_token="access_token")
Sign In or Register to comment.