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.84k stars 1.94k forks source link

[kraken] Failing to subscribe to websocket API - Unsupported field error #3542

Closed wvos closed 3 years ago

wvos commented 4 years ago

The Kraken streaming API doesn't work for a number of subscriptions. Using the below code works perfectly fine for other exchanges but gives a consistent error for Kraken

Code

exchange = StreamingExchangeFactory.INSTANCE.createExchange(KrakenStreamingExchange.class.getName());

exchange.connect().blockingAwait();

Disposable sub = exchange.getStreamingMarketDataService()
                .getOrderBook(CurrencyPair.BTC_USD)
                .subscribe(orderBook -> LOG.info("Order book: {}", orderBook));

Error/logs 01:38:23.437 [main] INFO info.bitrich.xchangestream.kraken.KrakenStreamingService - Subscribing to channel book-BTC/USD 01:38:23.475 [nioEventLoopGroup-2-1] INFO info.bitrich.xchangestream.kraken.KrakenStreamingService - System status: KrakenSystemStatus{connectionID='18409444206880552937', event='systemStatus', status='online', version='1.0.1'} 01:38:23.668 [nioEventLoopGroup-2-1] ERROR info.bitrich.xchangestream.kraken.KrakenStreamingService - Channel book-BTC/USD has been failed: Unsupported field: 'error' for the given msg type: subscribe

badgerwithagun commented 4 years ago

Hmm, looks like the socket's sending an error back from the subscribe request and KrakenStreamingService doesn't know how to interpret it. That's hiding the real cause of the error.

wvos commented 4 years ago

Indeed, the serialized subscription message has an 'error' field which is not part of the spec, and also a couple of null fields which causes it to fail

mdvx commented 4 years ago

The Kraken Spec is unreliable, and you need to look at the Margin API, Futures API as well as the spot API

nielsdraaisma commented 4 years ago

Is this issue still relevant?, the code above seems to match to what's happening in KrakenManualExample and that example seems to work fine.

If this is still happening it would be great if the actual message could be reported back here to it can be added to the testsuite.

earce commented 3 years ago

Fix was merged in