Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
Closing WebSocket connection

I already have SDK with WS connection, but it has no method to close it. In documentation has been said:

 * @deprecated This method is no longer functional. Please use the returned {@link Closeable} from any of the other methods to close the web socket.
 
@Override
public void close() { }

private Closeable createNewWebSocket(String channel, BinanceApiWebSocketListener<?> listener) {
    String streamingUrl = String.format("%s/%s", BinanceApiConfig.getStreamApiBaseUrl(), channel);
    Request request = new Request.Builder().url(streamingUrl).build();
    final WebSocket webSocket = client.newWebSocket(request, listener);
    return () -> {
        final int code = 1000;
        listener.onClosing(webSocket, code, null);
        webSocket.close(code, null);
        listener.onClosed(webSocket, code, null);
    };
}

So, how can I write close function to close my connection? Or get this @link Closeable? https://github.com/binance-exchange/binance-java-api/blob/8d38e8e63c8bf125aff963bac0284961af0630e6/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It seams to me that the method returns with the Closeable. And this is true for not just the createNewWebSocket(..)...

In the github readme they explain it this way: https://github.com/binance-exchange/binance-java-api#closing-web-sockets

Closable ws = client.onAggTradeEvent("ethbtc", someCallback);
// some time later...
ws.close();

So you should not close the client, but the called method's return-object (the Closable ws).

In the the link you posted, it looks like many methods return with such Closeables.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda