101 Switching Protocols. HTTP/1.1 403 Forbidden

noft

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
  • sujith
    Can you paste the complete code here?
    You may also print and check what are the values you are sending.
    This usually means your session is expired.
  • noft
    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?
  • rakeshr
    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)?
    Yes, it's 7:35 AM. You can know more about this here.
    And is there some problem with session reactivation if the session is deactivated coz of "Too many requests" or "Session expired" kinda reasons?
    No, the new session generation is independent of both the above errors .
  • Sandeep_Prakash
    @sujith I got this error too. It is generated from the following line of code. And I started the program at 08:48 as a cronjob.

    kiteTicker.connect();

    Since connect() doesn't throw any exception, we would be unable to catch it. I may be wrong.
  • rakeshr
    403
    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?
  • Sandeep_Prakash
    @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.
  • larabrian
    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.

  • raul
    I was getting the same error. The reason was wrong api key in
    kiteTicker = new KiteTicker(kiteConnect.getAccessToken(), kiteConnect.getApiKey());
  • xm1160
    @sujith I am suddenly getting this error, I have tried re login multiple times. Is there some issue with kite server?
  • sujith
    Did you log into any of our platforms or kiteconnect app?
  • xm1160
    No, i did not
  • dhavalsoni2001
    I am also getting same error web socket connection keep failing and throwing 403
  • xm1160
    Once It logged out, I logged in to check if zerodha's server was down
  • bhushanp
    bhushanp edited April 2023
    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))

    @sujith Please help
  • Wattnex_trade
    ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))

    same error - @sujith - please help
  • rakeshr
    @bhushanp @Wattnex_trade
    We are checking on this.
  • cnavani
    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
  • xm1160
    Working again :smile:
  • santab
    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)
  • sujith
    Can you private message the api_key, we will check and get back to you.
Sign In or Register to comment.