LTP of Multiple Shares Throwing IllegalStateException

Srikrishna_Rowthu
I am trying to retrieve ltp of multiple shares and I am getting an exception "IllegalStateException". But, if i loop the share list and retrieve each share ltp seperately, then there is no issue. Currently in my case, I am trying to retrieve 902 symbol LTP's (<1000). As far as i remember one can retrieve upto 1000 symbol LTP's in one go. I donot understand how to fix this. Can you check on this one?
  • Srikrishna_Rowthu
    Below is the exception caught

    java.lang.IllegalStateException: closed
    at okio.RealBufferedSource.select(RealBufferedSource.kt:220)
    at okhttp3.internal.Util.readBomAsCharset(Util.kt:256)
    at okhttp3.ResponseBody.string(ResponseBody.kt:187)
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:24)
    at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(KiteRequestHandler.java:152)
    at com.zerodhatech.kiteconnect.KiteConnect.getLTP(KiteConnect.java:719)
  • sujith
    Can you mention the javakiteconnect version you are using and run in debug mode and paste the stacktrace here?

    PS: Make sure to remove app and client-specific tokens.
  • Srikrishna_Rowthu
    The stack trace I did post it and it could be seen once approved since it's big. Meanwhile when i used debug mode, i see "414 Request-URI Too Large".

    1) Can you tell me how many characters are allowed in the request url, so that I can reduce the number of shares in one call. If there is any other better solution, please let me know.

    2) There are too much information during the debug mode, i would like to restrict to just "Request" and "Response" and any "errors". That's all , can you suggest me how to do it.
  • sujith
    A 414 is a standard HTTP status code. It is not something that is imposed by Kite Connect. Since different tokens are of different lengths, you need to do some trial and error.

    The debug logs print request header and body with response header and body. There is no additional filter for that. You can fork the library and add it. javakiteconnect is an open source project.
  • Srikrishna_Rowthu
    414 is a standard HTTP Status code,but it still depends on the server to candle the number of characters. I will do trail and error on this however.

    For the debug logs, i will try to check on that, thanks for the suggestion.
  • Srikrishna_Rowthu
    I have tested number of symbols to pass at one time for retrieving ltp values. People can make use of this if required.

    Allowed number of characters in the url- 14720 (some near number above this value)
    "https://api.kite.trade/quote/ltp" (35 characters)
    For every symbol [9 extra count, 9 here belongs to "NSE%3A" and ("?i=" or "&i=")]

    So identify number of symbols based on this information for each iteration of retrieving ltp values and then you can loop multiple times till your list of symbols are checked.
Sign In or Register to comment.