Issue with my Kite Ticker WebSocket connection, which is consistently failing with a 403 - Forbidden error. I have performed extensive troubleshooting and diagnostics from my end, and I believe the issue requires server-side investigation.
My setup involves a Python bot running on a Raspberry Pi, integrating with the Kite Connect API. While the REST API (for authentication, holdings, etc.) is working perfectly, the real-time data WebSocket connection is consistently rejected.
Error Message in my Application Logs (consistent):
Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden)) CRITICAL - Kite Ticker Error: Code=1006, Reason=connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden)) Timestamp of a recent failed attempt:
Kite Ticker expects valid credentials for connecting to the ticker. If you see a '403' error, then it means either api_key is invalid or the access token is invalid. You may go the similar discussion here.
wss://ws.kite.trade/?api_key=&access_token=&ci=py
PSB for the response:
Handshake Details
Request Method: GET
Status Code: 403 Forbidden
Request Headers
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: pXAL8DWS5TcV0fPWWONKaA==
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Host: ws.kite.trade
Response Headers
Date: Thu, 03 Jul 2025 06:18:29 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 53
Connection: keep-alive
python3 test_ticker.py
2025-07-03 12:12:50,972 - INFO - Using API Key: y5syxmuizyt13u1v and Access Token (first 5 chars): nZ6MR...
2025-07-03 12:12:50,972 - INFO - Attempting to connect Kite Ticker...
2025-07-03 12:12:51,132 - ERROR - Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:51,132 - ERROR - Kite Ticker Error: Code=1006, Reason=connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:51,132 - ERROR - Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:51,133 - INFO - Kite Ticker Connection Closed: Code=1006, Reason=connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:53,917 - ERROR - Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:53,917 - ERROR - Kite Ticker Error: Code=1006, Reason=connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:53,917 - ERROR - Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:53,918 - INFO - Kite Ticker Connection Closed: Code=1006, Reason=connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
2025-07-03 12:12:53,918 - WARNING - Kite Ticker Reconnecting (Attempt 1)...
2025-07-03 12:12:57,082 - INFO - Kite Ticker connection attempt finished (script exited or disconnected).