How to check the websocket connection status with the Binance Java connector ?

Hello,

I’m using the Binance Java connector.

Can anyone tell me how can I check the websocket connection?

I need to detect when it fails to stop activities when that happens .

Thanks.

Data should be pushed constantly when you connect to a stream. If you fail to receive message based on the Update Speed in the API documentation, you should attempt a reconnect.

Thank you Chai, but that doesn’t calm my concerns.

For example, I can’t rely on balance updates from websocket, whose connection may get broken at any time, as I’ve no mean to know whether my data is up to date to use it or stale an go get it from api.

I need a way, a realiable way, of checking the ws connection status.

Or, at least.

We need to have the possibility to have callbacks of our own, for connection failure or closure events, get called when such things happen.

That way, as long as my ‘failure’ callbacks hasn’t been called, I can consider that the program is in sync with the exchange and it can continue doing its job safely.

The binance java SDK websocket client doesn’t provide such thing.