issue in web-socket stream live (error:400)

yj3867
I am new to Python client for the Kite Connect trading API. I am trying to run the official example of KiteTicker, I am getting the following error:


Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (400 - BadRequest))
Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (400 - BadRequest))

my code=

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


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


kws = KiteTicker(api_key,access_token)
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.connect()
  • sujith
    Are you sure you are passing a valid api_key and access_token?
  • yj3867



    i am using this access token and api key
  • rakeshr
    @yj3867
    Your above WebSocket code is correct. And the source from which you are using api_key and access_token is also correct. So, can you once recheck that you are passing both api_key and access_token as a string for error mentioned in the log as 400 - BadRequest?
    eg: api_key = 'XXXXXX'
    access_token = 'XXXXX'
    kws = KiteTicker(api_key,access_token)
  • yj3867
    Thank you the error is solved
This discussion has been closed.