Weak Kite->OMS subsystem?

I use the Java SDK v3.3.2. I poll getMargins() every 10s to check if connection is alive. Multiple times during the day esp when there're large market moves, I see Kite calls fail with NetworkException. The app runs in the cloud, so actual network is not the issue for these many failures.

10:10:59 [scheduler-pool-3] c.o.t.b.KiteClientMgr - Err in kite login check
com.zerodhatech.kiteconnect.kitehttp.exceptions.NetworkException: null
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:58)
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:20)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(KiteRequestHandler.java:54)
at com.zerodhatech.kiteconnect.KiteConnect.getMargins(KiteConnect.java:257)

Network exception is described as Represents a network issue between Kite and the backend Order Management System (OMS). Default code is 503.
  • Does this mean the OMS backend is not strong enough to handle surge loads? If yes, is the problem being worked on?
  • If I get this error when placing a trade, can it mean the order might have been placed and we need to wait for order events/poll orders before retrying?
  • Can this error ever mean we need to refresh the auth token? Should we re-trigger login flow when this happens?
  • trd1
    Related bug report - I've noticed this error as well when running getMargins(). Maybe connection handling in the SDK needs to be looked into as well?
    java.lang.IllegalStateException: closed
    at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:408)
    at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:402)
    at okhttp3.internal.Util.bomAwareCharset(Util.java:469)
    at okhttp3.ResponseBody.string(ResponseBody.java:175)
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:24)
    at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(KiteRequestHandler.java:54)
    at com.zerodhatech.kiteconnect.KiteConnect.getMargins(KiteConnect.java:257)
  • trd1
    @Kailash could you please have someone from engineering look at this? Java Kite API does not seem reliable in prod
  • sujith
    It could be because the response.body().string() is read second time in this https://github.com/zerodha/javakiteconnect/blob/master/kiteconnect/src/com/zerodhatech/kiteconnect/kitehttp/KiteResponseHandler.java#L24

    You can fork the code and modify. We will add the fix in next release.

    We recommend not to poll margins every 10 seconds. You will have to catch exception and retry. It has nothing to do with session management. You need to create new access token only if you see 403 status code. If you don't want to see those many errors, we suggest you switch to getHoldings to check if connection is alive.
  • trd1
    Thanks for looking into this @sujith will look forward to the next update and change to getholdings. Is there a plan to improve the oms sustem availability?
Sign In or Register to comment.