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) at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54) at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3244) at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:3123) at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2155) at com.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:214) at com.aero.core.flow.TickCollectorStep.initializeTicker(TickCollectorStep.java:165) at com.aero.core.flow.TickCollectorStep.onError(TickCollectorStep.java:254) at com.zerodhatech.ticker.KiteTicker.subscribe(KiteTicker.java:400) at com.aero.core.flow.TickCollectorStep.onConnected(TickCollectorStep.java:218) at com.zerodhatech.ticker.KiteTicker$3.onConnected(KiteTicker.java:243) at com.neovisionaries.ws.client.ListenerManager.callOnConnected(ListenerManager.java:189) at com.neovisionaries.ws.client.WebSocket.callOnConnectedIfNotYet(WebSocket.java:3457) at com.neovisionaries.ws.client.WebSocket.onReadingThreadStarted(WebSocket.java:3398) at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:86) at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
com.zerodhatech.kiteconnect.kitehttp.exceptions.KiteException: null at com.zerodhatech.ticker.KiteTicker.subscribe(KiteTicker.java:400) [kiteconnect-3.0.0.jar!/:na] at com.aero.core.flow.TickCollectorStep.onConnected(TickCollectorStep.java:218) [classes!/:0.1.0-SNAPSHOT] at com.zerodhatech.ticker.KiteTicker$3.onConnected(KiteTicker.java:243) [kiteconnect-3.0.0.jar!/:na] at com.neovisionaries.ws.client.ListenerManager.callOnConnected(ListenerManager.java:189) [nv-websocket-client-2.3.jar!/:na] at com.neovisionaries.ws.client.WebSocket.callOnConnectedIfNotYet(WebSocket.java:3457) [nv-websocket-client-2.3.jar!/:na] at com.neovisionaries.ws.client.WebSocket.onReadingThreadStarted(WebSocket.java:3398) [nv-websocket-client-2.3.jar!/:na] at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:86) [nv-websocket-client-2.3.jar!/:na] at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) [nv-websocket-client-2.3.jar!/:na] at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45) [nv-websocket-client-2.3.jar!/:na]
From last week, we have started hitting error while collecting tick values and the connection fails. Above is the error that was encountered today. We collect ticks for 45 instruments using a single connection and we try to reconnect if the connection fails as given in the example.
This happens when you have more open connections. You need to make sure you close the connection properly before starting a new one. If there are abrupt disconnections be it when the script is suspended or close or network disconnection, it leaves a hanging connection at the server, this is still counted while checking the total. You need to always make sure the existing connection is closed gracefully before starting a new one.
You don't have to call disconnect inside onDisconnected. Apart from that code looks fine. While this looks fine, it is difficult to comment since we don't know the complete code. You just need to check all the edge cases and make sure you are disconnecting the ticker connection before exiting.
@sujith thanks a lot for the prompt responses, will try the suggestion.
To confirm, I do not need to call the DISCONNECT or the RE-INITIALIZATION from onDisconnected(). In case the connection is broken, it will try to auto-reconnect and if that fails, we will hit the onError(). Hope my understanding is correct.
While this looks fine, it is difficult to comment since we don't know the complete code. You just need to check all the edge cases and make sure you are disconnecting the ticker connection before exiting.
To confirm, I do not need to call the DISCONNECT or the RE-INITIALIZATION from onDisconnected(). In case the connection is broken, it will try to auto-reconnect and if that fails, we will hit the onError(). Hope my understanding is correct.
You don't need to handle disconnections. Kite Connect client library does it for you. You check out the example here.