KiteTicker gives 403 Forbidden error

ruchanavjyot1907
Hello,

While trying to connect using KiteTicker, it gives me 403 error. As far as I am concerned, it is typically thrown when user is not authorized on server. Could you please check and let me know reason for this.

PFB logs for analysis:
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:3113)
at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:2992)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2034)
at com.TradeRobotBatch.api.KiteAPI.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:195)
at com.TradeRobotBatch.api.KiteAPI.zerodhatech.ticker.KiteTicker.reconnect(KiteTicker.java:625)
at com.TradeRobotBatch.api.KiteAPI.zerodhatech.ticker.KiteTicker.access$200(KiteTicker.java:30)
at com.TradeRobotBatch.api.KiteAPI.zerodhatech.ticker.KiteTicker$2.run(KiteTicker.java:126)
  • ruchanavjyot1907
    Please ignore above error, socket has been connected. However, I am unable to receive ticks. I am subscribing for MCX instrument tokens (53502215, 53505031) but receiving back ArrayList ticks with zero ticks in it. I have also tried with exchange tokens (i.e. 208993, 209004) but again same problem. Please guide me how shall I subscribe tokens to receive ticks.
  • ruchanavjyot1907
    Moreover, application gets crashed when I enable logging (KiteConnect.ENABLE_LOGGING = true). I have pasted error log below, getting exception java.lang.ClassNotFoundException: okhttp3.internal.Platform

    It looks like due to some version mismatch within okhttp dependency. Could you please let me know which version of okhttp did you guys use?
    Caused by: java.lang.NoClassDefFoundError: okhttp3/internal/Platform
    at okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:108)
    at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:157)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
    at okhttp3.RealCall.execute(RealCall.java:63)
    at com.TradeRobotBatch.api.KiteAPI.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:59)
    at com.TradeRobotBatch.api.KiteAPI.zerodhatech.kiteconnect.KiteConnect.generateSession(KiteConnect.java:179)
  • ruchanavjyot1907
    ruchanavjyot1907 edited January 2018
    @sujith yes I have same dependency but giving me error, finally resolved with some previous version 3.2.0 i.e.
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <!-- <version>3.9.0</version>-->
    <version>3.2.0</version>
    </dependency>
    Moreover, could you please answer my earlier question on same thread regarding receiving ticks for MCX instruments.

    I am unable to receive ticks. I am subscribing for MCX instrument tokens (53502215, 53505031) but receiving back ArrayList ticks with zero ticks in it. I have also tried with exchange tokens (i.e. 208993, 209004) but again same problem. Please guide me how shall I subscribe tokens to receive ticks.
  • sujith
    You need to use instrument_token.
    It seems to be working fine for me. Are you sure you are not sending tokens as a string?
  • ruchanavjyot1907
    I am using ArrayList as specified in API (latest V3). Is it necessary to specify exchange code before subscribing to tick? I am trying for MCX instrument tokens (53502215, 53505031), can you try if it is working for you?
  • sujith
    Yes, I tried at my end and I got ticks.
    Exchange token won't work as it can repeat for some other instrument in another segment.
    Did you set the listener for onError?
Sign In or Register to comment.