KiteConnect object validity

chintanvhparmar
Hi,
This is a continuation of the previous thread related to session validity which is now closed.
I have written java code to continuously check the current time and place market order for predefined selected stock and quantity at end of day(3:29 PM IST) and i generate a request_token and start the process around 12 PM PST. The intention is to place an order for selected stock at end of day even if i am not available to place the order manually. While testing this code it seems there is some API exception after some time interval. Below is the exception message seen. This exception is seen sometimes after 1 hour and sometimes after 2 hours of code runtime. Please suggest how can we avoid this exception to have the program run successfully for sevral hours until end of day.

symb-ALKALI
Run1 start time 03:01 IST
Run1 exception time 04:01:09 IST


Run2 Start time 04:23:41 IST
Run2 exception time 06:00:24 IST


Below is the exception seen
com.rainmatter.kitehttp.exceptions.KiteNetworkException
at com.rainmatter.kitehttp.KiteRequest.dealWithKiteException(KiteRequest.java:276)
at com.rainmatter.kitehttp.KiteRequest.getRequest(KiteRequest.java:101)
at com.rainmatter.kiteconnect.KiteConnect.getQuote(KiteConnect.java:409)
at PlaceOrder.main(PlaceOrder.java:276)
Exception in thread "main" java.lang.NullPointerException
at PlaceOrder.main(PlaceOrder.java:286)
  • sujith
    Can you print kiteException.message?
  • sujith
    sujith edited December 2016
    And make sure you are not logging in from any other Zerodha trading platform in between.
  • chintanvhparmar
    Hi Sujith,
    Please find below test results and exception messages logged.
    Please suggest a way to avoid these exceptions.

    Test1:
    Start Time 13:45:32 IST

    Exception log Time(after almost 3 hours runtime) 16:33:40 IST
    symb-AARVEEDEN close->87.6
    before getQuote-AARVEEDEN
    Message->OMS timed out
    com.rainmatter.kitehttp.exceptions.KiteNetworkException
    at com.rainmatter.kitehttp.KiteRequest.dealWithKiteException(KiteRequest.java:276)
    at com.rainmatter.kitehttp.KiteRequest.getRequest(KiteRequest.java:101)
    at com.rainmatter.kiteconnect.KiteConnect.getQuote(KiteConnect.java:409)
    at PlaceOrder.main(PlaceOrder.java:277)
    Exception in thread "main" java.lang.NullPointerException
    at PlaceOrder.main(PlaceOrder.java:288)

    -----------------------
    Test2:

    Start Time 05:40:23 IST
    symb-AARVEEDEN
    before getQuote-AARVEEDEN

    Exception time(within 21 mins) 06:00:21 IST
    symb-AARVEEDEN close->87.6
    before getQuote-AARVEEDEN
    Message->Invalid HTTP status from OMS (503)
    com.rainmatter.kitehttp.exceptions.KiteNetworkException
    at com.rainmatter.kitehttp.KiteRequest.dealWithKiteException(KiteRequest.java:276)
    at com.rainmatter.kitehttp.KiteRequest.getRequest(KiteRequest.java:101)
    at com.rainmatter.kiteconnect.KiteConnect.getQuote(KiteConnect.java:409)
    at PlaceOrder.main(PlaceOrder.java:277)
    Exception in thread "main" java.lang.NullPointerException
    at PlaceOrder.main(PlaceOrder.java:288)


    Thanks,
    Chintan Parmar

  • sujith
    Hi @chintanvhparmar,

    I would suggest for now, you can catch exception and retry the same.
    We are working on making API more reliable, checkout https://kite.trade/forum/discussion/943/update-revamping-of-core-api-infrastructure#latest
Sign In or Register to comment.