Kite WebSocket failing with 403 Forbidden handshake (HTTP APIs work fine)

KMB038
Forum Post Body:

Hi team,

I am unable to connect to the Kite Ticker WebSocket — the handshake fails every time with:

OpeningHandshakeException: HTTP/1.1 403 Forbidden
Expected status: 101 Switching Protocols


This happens even though my access token is valid and all HTTP Kite APIs work perfectly (profile API, instruments, etc.).

✅ What I have verified
1. Access token is valid

Calling /user/profile returns 200 OK with correct user details.

2. Minimal test client also fails

Even the absolute minimal Java test fails with the same 403:

KiteTicker ticker = new KiteTicker(apiKey, accessToken);
ticker.setTryReconnection(false);
ticker.connect();


No indicators, no custom logic — just a clean attempt.
Still returns 403 on handshake.

3. Tested across networks

Home Wi-Fi

Mobile hotspot
→ Same 403 error.

4. No reconnect loops

I disabled reconnection to capture the exact first error cleanly.

5. Multiple fresh access tokens

Generated new request tokens several times → same issue.

???? Suspicion

This looks like either:

IP / geo restriction

VPN detection (I used Tailscale earlier — now disabled, but the IP may have been flagged)

WS endpoint firewall

Developer app classification issue (HTTP allowed, WS blocked?)

Regional blocking for WebSocket traffic

Since HTTP works and only the WS handshake fails, it appears to be some kind of WS-specific restriction.

???? Request

Can someone from the team please check:

If my API key / user / IP is allowed to connect to wss://ws.kite.trade

Whether any WS restrictions exist for VPN-detected IPs

Whether developer apps can be restricted from WebSocket usage

If my current IP can be whitelisted or cleared from any blocklist

Happy to share:

API key (privately)

Timestamps of errors

Minimal test file

Logs

Thanks in advance.
This issue is blocking my live data integration, so any insight will be appreciated.
  • salim_chisty
    You may refer to the similar discussion here. Additionally, you may find it helpful to review the Java library example code for guidance.
  • KMB038
    KMB038 edited November 25
    Hi @salim_chisty and team,

    Quick update — this is now resolved.

    The root cause was exactly what was mentioned in the older discussion you linked:
    I was constructing the Java KiteTicker with the parameters in the wrong order.

    I had this in my code:

    // ❌ Wrong
    KiteTicker ticker = new KiteTicker(apiKey, accessToken);


    But the correct constructor signature is:

    // ✔ Correct
    KiteTicker ticker = new KiteTicker(accessToken, apiKey);


    Once I swapped the arguments to (accessToken, apiKey), the WebSocket handshake started succeeding immediately:

    HTTP APIs were already working with the same api_key + access_token

    After fixing the parameter order, KiteTicker connected and ticks started streaming as expected

    No more OpeningHandshakeException: HTTP/1.1 403 Forbidden

    Thank you for pointing me to the earlier thread — it saved me a ton of time and will surely help others who hit the same 403 issue.

    Marking this as solved.
This discussion has been closed.