knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.82k stars 1.93k forks source link

[Binance][Streaming] Binance trades streaming doesn't work #4029

Open Flamarial opened 3 years ago

Flamarial commented 3 years ago

Version: 5.0.7

I've encountered some trouble with streaming Binance. I subscribe at connect time with a ProductSubscription,. but I don't seem to be getting any messages through at all via subscribe(). I'm running the most basic example in Android:

new Thread(() -> {
            ExchangeSpecification spec = StreamingExchangeFactory.INSTANCE.createExchange(BinanceStreamingExchange.class).getDefaultExchangeSpecification();
            BinanceStreamingExchange exchange = (BinanceStreamingExchange) StreamingExchangeFactory.INSTANCE.createExchange(spec);

            ProductSubscription subscription = ProductSubscription.create().addTrades(CurrencyPair.BTC_USDT).build();
            exchange.connect(subscription).blockingAwait();
            exchange.getStreamingMarketDataService()
                    .getTrades(CurrencyPair.BTC_USDT)
                    .subscribe(trade -> {
                        Log.i(TAG, "Trade: " + trade);
                    });
        }).start();

The same exact code refactored with KrakenStreamingExchange works 100% fine. Likewise, directly subscribing to the Binance WebSockets API without the use of this library works fine as well.

M1K commented 2 years ago

The same here. I tried Bitfinex, CoinbasePro, Kraken etc. and everywhere I am getting messages. But from Binance nothing. There is just message: Subscribing to channel btcusd@trade and then nothing

n-dragon commented 2 years ago

same here

Svenmet commented 2 years ago

Same problem here

mrmx commented 2 years ago

It's working, at least with latest 5.0.14-SNAPSHOT version.