I am running below code for web-socket streaming code from your github doc. I have replaced my api key and token from browser just for security concern. I am getting below output. Could you please help me what could be the reason for 1006 error? I have update python client and tried with switching off my windows firewall.
(base) \kiteconnect_workspace>python buy_strategy.py https://kite.zerodha.com/connect/login?api_key=MY_API_KEY&v=3 Enter access tokenTOKEN_FROM_BROWSER ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (I dropped the WebSocket TCP connection: close reason without close code) ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (I dropped the WebSocket TCP connection: close reason without close code)
# Redirect the user to the login url obtained # from kite.login_url(), and receive the request_token # from the registered redirect url after the login flow. # Once you have the request_token, obtain the access_token # as follows.
data = kite.generate_session(request_token, api_secret="t4vztb2lk98upfaq6vzr2taredna17rv") kite.set_access_token(data["access_token"])
kws = KiteTicker(api_key, data["access_token"])
def instrumentLookup(instrument_df,symbol): """Looks up instrument token for a given script from instrument dump""" try: return instrument_df[instrument_df.tradingsymbol==symbol].instrument_token.values[0] except: return -1
def on_ticks(ws, ticks): # Callback to receive ticks. logging.debug("Ticks: {}".format(ticks))
def on_connect(ws, response): # Callback on successful connect. # Subscribe to a list of instrument_tokens (RELIANCE and ACC here). ws.subscribe(tokens)
# Set RELIANCE to tick in `full` mode. ws.set_mode(ws.MODE_FULL, tokens)
def on_close(ws, code, reason): # On connection close stop the main loop # Reconnection will not happen after executing `ws.stop()` ws.stop()