binance / binance-futures-connector-java

MIT License
111 stars 61 forks source link

WebSocket onFailure Why not return the connection information at that time #15

Open disciplinary opened 1 year ago

disciplinary commented 1 year ago

![Uploading image.png…]() WebSocketConnection.onFailure,

 @Override
    public void onFailure(WebSocket ws, Throwable t, Response response) {
        logger.error("[Connection {}] Failure", connectionId, t);
// Wouldn't it be better to just return null and return the connectionId
        onFailureCallback.onReceive(null);
    }

If one of the multiple subscriptions is disconnected, how do you retry without knowing the current subscription information Or throw the exception out

aisling-2 commented 6 months ago

Ideally, the method should be:

    @Override
    public void onFailure(WebSocket ws, Throwable t, Response response) {
        logger.error("[Connection {}] Failure", connectionId, t);
        onFailureCallback.onFailure(t, response);
    }

So that the WS connection's Failure Callback can get more information when failure is detected and define how to handle next. We haven an internal ticket to solve this in the future.