binance-exchange / binance-java-api

binance-java-api is a lightweight Java library for the Binance API, supporting synchronous and asynchronous requests, as well as event streaming using WebSockets.
MIT License
831 stars 628 forks source link

Binance aggTrade for multiple streams is not working #376

Open kaushik1979 opened 3 years ago

kaushik1979 commented 3 years ago

Hi,

I have an issue with the binance aggTrade api for future data. As per the api doc, when I create a streaming link and open a websocket with it, no data comes back.

streamingUrl - wss://fstream.binance.com/ws/stream?streams=btcusdt@aggTrade/ethusdt@aggTrade/bnbusdt@aggTrade

However, the link for single future contract works like a charm.

streamingUrl - wss://fstream.binance.com/ws/btcusdt@aggTrade

API Doc - https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams

Code establishing websocket connection -

import static com.binance.api.client.impl.BinanceApiServiceGenerator.getSharedClient;

client = getSharedClient().newBuilder().pingInterval(3, TimeUnit.MINUTES).build();

...
...

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);
};

Can someone help me resolve this issue please?