Error - The current state of the WebSocket is not CREATED

vSeelin
I have a toggle switch on a JavaFx window to provide a connect / disconnect feature for RealTime data.

The first time I click the Toggle Switch the RT data streams fine & when I click the Toggle Switch again it stops. So far so good.

But when I click the Toggle Switch again to re-start streaming data, I get the below error. I guess the error is because tickerProvider.disconnect(); closes the websocket.

Any suggestions how I can restart the websocket, without having to stop the entire program & restart?

Am using the same code available at - https://github.com/zerodhatech/javakiteconnect under WebSocket live streaming data.



com.neovisionaries.ws.client.WebSocketException: The current state of the WebSocket is not CREATED.
at com.neovisionaries.ws.client.WebSocket.changeStateOnConnect(WebSocket.java:3088)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2144)
at com.zerodhatech.ticker.KiteTicker.connect(KiteTicker.java:214)
at utilities.utilsController.TickerDataKite.tickerUsage(TickerDataKite.java:117)
at controller.TradeMainController.lambda$initialize$0(TickerMainController.java:219)
at java.base/java.lang.Thread.run(Thread.java:835)
Sign In or Register to comment.