KiteNetworkException is thrown frequently by getQuote() API call. It fails with below exception message every 8th time when it is called in a loop. Because of this my trades are failing. Please help me on this ASAP.
Below is the sample code which proves the failure. To this main methos I pass the access token and public token as arguments.
public static void main(String[] args) throws JSONException, KiteException { KiteConnect kiteConnect =new KiteConnect("nuvzsoxbmp7k78ti"); kiteConnect.setAccessToken(args[0]); kiteConnect.setPublicToken(args[1]); int i=0; while (i <10) { Quote quote = kiteConnect.getQuote("NSE", "BANKINDIA"); System.out.println("BANKINDIA CMP:" +quote.lastPrice); i++; } }
Below is the result of this. Every run, it fails exactly at the 7th or 8th time. To avoid this I implemented retry logic when the exception occurs, but still no luck it fails at the same place.
BANKINDIA CMP:201.1 BANKINDIA CMP:201.1 BANKINDIA CMP:201.1 BANKINDIA CMP:201.1 BANKINDIA CMP:201.1 BANKINDIA CMP:201.1 Exception in thread "main" com.rainmatter.kitehttp.exceptions.KiteNetworkException at com.rainmatter.kitehttp.KiteRequest.dealWithKiteException(KiteRequest.java:367) at com.rainmatter.kitehttp.KiteRequest.getRequest(KiteRequest.java:87) at com.rainmatter.kiteconnect.KiteConnect.getQuote(KiteConnect.java:447) at com.exp.GetQuote.main(GetQuote.java:19)
You are calling the API in a while loop and this is leading to rate limiting. There is a limit of 3 requests/second. You can put a delay in the loop to avoid this.
You are calling the API in a while loop and this is leading to rate limiting. There is a limit of 3 requests/second. You can put a delay in the loop to avoid this.