com.neovisionaries.ws.client.OpeningHandshakeException: The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: HTTP/1.1 403 Forbidden Since afternoon of 31st August 2021, I am getting the above error and havent been able to reconnect Have logged in multiple times to the kite and generated the token bt still getting the same error
Yes. Usually logging in again used to solve this problem. Is there a cut off in the morning (say 8:30 am) before which all sessions are expired, even if created the same day (say 8:15 am)? And is there some problem with session reactivation if the session is deactivated coz of "Too many requests" or "Session expired" kinda reasons?
Means the session has expired or you are using the wrong access token. Can you re-check, if you are able to make other API call with the same access token?
@rakeshr True, this happens due to session expiry and we will not be able to make any further API calls. But here the scenario is that session expiry happens at Websocket stage. I mean after kiteTicker = new KiteTicker(kiteConnect.getAccessToken(), kiteConnect.getApiKey()); login and stuff. We establish a Websocket after the KiteConnect has logged in. And the time is after 07:35 which rules out the session token flushing scenario. I will post the exact log if and when I hit this scenario again. Strange thing is that I don't hit on this exception always.
This error indicates that the server has determined that you are not allowed access to the thing you've requested, either on purpose or due to a misconfiguration . It's probably because the site owner has limited access to it and you don't have permission to view it. The vast majority of the time, there's not much you can do to fix things on your (*client) end. There are four common causes for 403 Forbidden error (server side) . Here they are listed from most likely to least likely:
An empty website directory
No index page
Incorrect settings in the .htaccess file
Permission / Ownership error
If authentication credentials were provided in the request, the server considers them insufficient to grant access. The client SHOULD NOT automatically repeat the request with the same credentials. The client MAY repeat the request with new or different credentials. However, a request might be forbidden for reasons unrelated to the credentials.
Getting below error in python client. Multiple times tried to logout and and login .. still no success==>
WS closed due to 1006 connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time)) 2023-04-25 16:59:54.002245 ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time)) ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))
ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))
As mentioned on other thread, I am also getting this error. Also, I am just using my single app. I dont use any other platforms. It was all fine till 4PM and then it stopped working. Also note all other API calls are working. Just streaming websocket seems to have problems
This error has started again this morning. Usually the time for refreshing the request token is around 7:30 AM. But today logging in with new request token did not resolve. Please help @sujith . com.neovisionaries.ws.client.OpeningHandshakeException: The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: HTTP/1.1 403 Forbidden at com.neovisionaries.ws.client.HandshakeReader.validateStatusLine(HandshakeReader.java:232) at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54) at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3244) at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:3123) at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2155) at com.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:214) at com.zerodhatech.ticker.KiteTicker.reconnect(KiteTicker.java:652) at com.zerodhatech.ticker.KiteTicker.doReconnect(KiteTicker.java:128) at com.zerodhatech.ticker.KiteTicker$1.run(KiteTicker.java:105) at java.base/java.util.TimerThread.mainLoop(Timer.java:566) at java.base/java.util.TimerThread.run(Timer.java:516)
I've been trying to attempt through a new java program. Login is working fine, instrument cache also happening, however webSocket connection/kiteTicker is failing continuosly. The api key is correct, user token is valid and not expired. However I've been getting the following error. Please help @sujith ....com.neovisionaries.ws.client.OpeningHandshakeException: The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: HTTP/1.1 403 Forbidden at com.neovisionaries.ws.client.HandshakeReader.validateStatusLine(HandshakeReader.java:232) at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54) at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3244) at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:3123) at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2155) at com.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:214) at zerodhaproject1.Z_connect.lambda$initializeWebSocket$0(Z_connect.java:377) at java.base/java.lang.Thread.run(Thread.java:1447)
The instruments file fetch doesn't have authentication for legacy purposes. You may make any other API call and check if the access token is valid or not. 403 usually means session expired.
Or make sure you have a Kite Connect app on the developers console. The Kite personal app doesn't have access to Websockets API that also results in http status code 403.
My app is kite Connect app, It has "Kite connect + Historical Chart data (Created on 29 jul 2025)" mentioned in the app header, and subscription is valid till 29 Aug 2025. I’ve multiple times checked the validity of API key, secret and user token. The jar file being used is the latest javakiteconnect 3.5.1 version. Still I’m getting 101 Switching Protocols'. The status line is: HTTP/1.1 403 Forbidden.. Please advise.
Guys, can anyone of you share how did you resolve 101 Switching Protocols'. The status line is: HTTP/1.1 403 Forbidden issues. I've been trying to get this resolved, however unable to move forward, despite having verified validity of apikey, apisecret, usertoken again and again, several times.
Just now got the issue resolved. The api_key and access token are valid. The sequence of passing them in KiteTicker was incorrect. Will close the ticket as well.
You may also print and check what are the values you are sending.
This usually means your session is expired.
And is there some problem with session reactivation if the session is deactivated coz of "Too many requests" or "Session expired" kinda reasons?
kiteTicker.connect();
Since
connect()
doesn't throw any exception, we would be unable to catch it. I may be wrong.kiteTicker = new KiteTicker(kiteConnect.getAccessToken(), kiteConnect.getApiKey());
login and stuff.We establish a Websocket after the KiteConnect has logged in. And the time is after 07:35 which rules out the session token flushing scenario.
I will post the exact log if and when I hit this scenario again.
Strange thing is that I don't hit on this exception always.
kiteTicker = new KiteTicker(kiteConnect.getAccessToken(), kiteConnect.getApiKey());
WS closed due to 1006 connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time)) 2023-04-25 16:59:54.002245
ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))
ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))
@sujith Please help
same error - @sujith - please help
We are checking on this.
com.neovisionaries.ws.client.OpeningHandshakeException: The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: HTTP/1.1 403 Forbidden
at com.neovisionaries.ws.client.HandshakeReader.validateStatusLine(HandshakeReader.java:232)
at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54)
at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3244)
at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:3123)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2155)
at com.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:214)
at com.zerodhatech.ticker.KiteTicker.reconnect(KiteTicker.java:652)
at com.zerodhatech.ticker.KiteTicker.doReconnect(KiteTicker.java:128)
at com.zerodhatech.ticker.KiteTicker$1.run(KiteTicker.java:105)
at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
at java.base/java.util.TimerThread.run(Timer.java:516)
at com.neovisionaries.ws.client.HandshakeReader.validateStatusLine(HandshakeReader.java:232)
at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54)
at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3244)
at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:3123)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2155)
at com.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:214)
at zerodhaproject1.Z_connect.lambda$initializeWebSocket$0(Z_connect.java:377)
at java.base/java.lang.Thread.run(Thread.java:1447)