xchange-stream
xchange-stream copied to clipboard
Gemini doesn't shut down properly
I think this has been a common theme with gdax as well, but I put together a sample program to demonstrate the issue.
Steps To Reproduce:
- Build the provided code using Java 1.8 or higher
- Run the application (no arguments required)
Expected Results
- The program connects to the Gemini web socket and the main thread blocks for 20 seconds.
- Once the 20 seconds is completed the program should properly shutdown the web socket and exit
Actual Results
- Although the clean up/disconnect code is called, the program hangs and does not exit
``
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.currency.CurrencyPair;
import info.bitrich.xchangestream.core.StreamingExchange;
import info.bitrich.xchangestream.core.StreamingExchangeFactory;
import info.bitrich.xchangestream.gemini.GeminiStreamingExchange;
import io.reactivex.disposables.Disposable;
public class Application {
public static void main(String[] args) {
ExchangeSpecification exSpec = new GeminiStreamingExchange().getDefaultExchangeSpecification();
StreamingExchange ex = StreamingExchangeFactory.INSTANCE.createExchange( exSpec );
ex.connect().blockingAwait();
Disposable sub = ex.getStreamingMarketDataService()
.getOrderBook(CurrencyPair.ETH_USD)
.subscribe(orderBook -> {
System.out.println(orderBook);
}, throwable -> {
System.err.println("Error in subscribing to order book " + throwable);
});
synchronized (Application.class) {
try { Application.class.wait(20000); } catch (Exception e) {}
}
System.out.println("Starting Shutdown");
sub.dispose();
ex.disconnect().subscribe(() -> System.out.println("Disconnected from the Exchange {}"));
}
}