error in kiteticker - (WebSocket connection upgrade failed (403 - Forbidden))

Kuppuraj
hi,
I have gone through some of above subjected issues but unable to fix. You are saying that need to kill the access_token using invalid_access_token however it also wont work.

but access token is working very well in kiteconnect and i am able to download instruments. but same access_token is not working i guess.

Below is my code which is given by you one of the solution in the forum.

logging.basicConfig(level=logging.DEBUG)

# Initialise
kws = KiteTicker(api_key , access_token )

def on_ticks(ws, ticks): # noqa
# Callback to receive ticks.
logging.info("Ticks: {}".format(ticks))

def on_connect(ws, response): # noqa
# 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])

def on_order_update(ws, data):
logging.debug("Order update : {}".format(data))

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

# 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
    The instruments master filed doesn't check for authentication. Hence you are able to fetch data without valid access token as well.
    If you are getting 403 then you need to generate a new access token.
  • Kuppuraj
    receiving like below errors.

    ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
  • Kuppuraj
    Sujith,
    i am able to dump the instruments using the same access_token in KiteConnect. But, it is not working in KiteTicker. I regenerated and was used, even though it is not working.
  • sujith
    As mentioned above, instruments API doesn't require access token. You may refer to this thread to know more about access token generation.
  • Kuppuraj
    Thanks Sujith, it is connecting now however i have not properly closed the websocket therefore, i am getting below error in my next connection today, how to solve this.

    ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
  • sujith
    Are you sure, you are not blocking the thread that is receiving the ticks?
Sign In or Register to comment.