zerodha / pykiteconnect

The official Python client library for the Kite Connect trading APIs
MIT License
978 stars 467 forks source link

unable to get tick data error is "ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))" #102

Closed rjamitsharma01 closed 3 years ago

rjamitsharma01 commented 3 years ago

what is going wrong here in my code please tell me


import logging
from kiteconnect import KiteTicker

logging.basicConfig(level=logging.DEBUG)

kws = KiteTicker(api, token) // api is my api key and token is token got from url after login 

def on_ticks(ws, ticks):
    logging.debug("Ticks: {}".format(ticks))

def on_connect(ws, response):
    ws.subscribe([738561, 5633])
    ws.set_mode(ws.MODE_FULL, [738561])

def on_close(ws, code, reason):
    ws.stop()

kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close

kws.connect()

when i run this it shows error like "ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))"

please help me

vividvilla commented 3 years ago

Seems like either Apikey or access token is invalid while initializing the connection.