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());
Sign In or Register to comment.