Today (10th June 2024) after 14:11 i started receiving ``` 2024-06-10 14:11:05.472 ERROR 7637 --- [Timer-173] c.s.i.t.service.LiveTickerServiceImpl : Kite connect exception {}
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 429 Too Many Requests at com.neovisionaries.ws.client.HandshakeReader.validateStatusLine(HandshakeReader.java:232) ~[kiteconnect.jar!/:1.11] at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54) ~[kiteconnect.jar!/:1.11] at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3244) ~[kiteconnect.jar!/:1.11] at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:3123) ~[kiteconnect.jar!/:1.11] at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2155) ~[kiteconnect.jar!/:1.11] at com.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:214) [kiteconnect.jar!/:1.11] at com.zerodhatech.ticker.KiteTicker.reconnect(KiteTicker.java:648) [kiteconnect.jar!/:1.11] at com.zerodhatech.ticker.KiteTicker.doReconnect(KiteTicker.java:128) [kiteconnect.jar!/:1.11] at com.zerodhatech.ticker.KiteTicker$1.run(KiteTicker.java:105) [kiteconnect.jar!/:1.11] at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_362] at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_362] ```
public void onConnected() { /** * Subscribe ticks for token. By default, all tokens are * subscribed for modeQuote. */ log.info("Live ticker connected"); tickerProvider.subscribe(tradeTokens); tickerProvider.setMode(tradeTokens, KiteTicker.modeFull); } });
tickerProvider.setTryReconnection(true); // maximum retries and should be greater than 0 tickerProvider.setMaximumRetries(5000); // set maximum retry interval in seconds tickerProvider.setMaximumRetryInterval(30);
/** * connects to com.zerodhatech.com.zerodhatech.ticker server for getting * live quotes */ tickerProvider.connect();
In todays log i found that multiple times websocket got disconnected. Is there a possibility that these disconnections and re-connections did not perform a proper connection cleanup leading to more than 3 active connection? if yes what could be solution in this case?
Are you sure you are disconnecting properly? It could be because you have not closed the connection at your end but server has an active state at its end and hence you are getting too many requests.
I think that is very difficult to solve because on the client machine it is disconnected. I think it is better to check why it is getting disconnected in the first place. One shouldn't block the thread that is receiving ticks. If you have taken care of that then add try catch blocks in secondary thread.
i have deployed my code on aws ec2 instance, i think disconnection could be because of some network fluctuations (maybe). My main thread which receives tick data is not blocked from rest of the code, it only receives tick data and pushes it into another queue. If i invalidate my session and do a fresh connection then connection count be reset ?
public void onConnected() {
/**
* Subscribe ticks for token. By default, all tokens are
* subscribed for modeQuote.
*/
log.info("Live ticker connected");
tickerProvider.subscribe(tradeTokens);
tickerProvider.setMode(tradeTokens, KiteTicker.modeFull);
}
});
tickerProvider.setOnDisconnectedListener(new OnDisconnect() {
@Override
public void onDisconnected() {
log.error("Live ticker disconnected");
}
});
tickerProvider.setOnErrorListener(new OnError() {
@Override
public void onError(Exception exception) {
// handle here.
log.error("Kite connect exception {}", exception);
}
@Override
public void onError(KiteException kiteException) {
// handle here.
log.error("Kite connect kite exception {}", kiteException);
}
@Override
public void onError(String s) {
log.error("Kite connect string exception {}", s);
}
});
tickerProvider.setTryReconnection(true);
// maximum retries and should be greater than 0
tickerProvider.setMaximumRetries(5000);
// set maximum retry interval in seconds
tickerProvider.setMaximumRetryInterval(30);
/**
* connects to com.zerodhatech.com.zerodhatech.ticker server for getting
* live quotes
*/
tickerProvider.connect();
In todays log i found that multiple times websocket got disconnected. Is there a possibility that these disconnections and re-connections did not perform a proper connection cleanup leading to more than 3 active connection?
if yes what could be solution in this case?
@sujith can you please with this
If you have taken care of that then add try catch blocks in secondary thread.
My main thread which receives tick data is not blocked from rest of the code, it only receives tick data and pushes it into another queue.
If i invalidate my session and do a fresh connection then connection count be reset ?