Comments (2)
it's not best solution, but it will be work
ExchangeClientFactory.websocket(ExchangeVendor.BINANCE)
.createDepthSnapshot(listOf(CurrencyPair(Currency.BTC, Currency.USDT)))
// retry when connetion drops
.doOnTerminate { throw RuntimeException("terminated!") }
.retryWhen { throwablePublisher ->
throwablePublisher
.doOnNext { log.error(it.message, it) }
.flatMap { Mono.delay(Duration.ofSeconds(2)) } // retry wait time
}
.doOnNext { /* do something you want */ }
half connection checker(ping/pong handler) not implemented in binance yet. so upper reconnection code is not work with half connection.
but other case it will work fine :).
from reactive-crypto.
while (true) {
try {
ExchangeWebsocketClient exchangeWebsocketClient = ExchangeClientFactory.websocket(ExchangeVendor.BINANCE);
List<CurrencyPair> targetPairs = Collections.singletonList(CurrencyPair.parse("BTC", "USDT"));
Flux<TickData> tickDataFlux = exchangeWebsocketClient.createTradeWebsocket(targetPairs);
// .doOnNext(tickData -> System.out.println(tickData.getQuantity()))
// .subscribe();
while (true) {
TickData tickData = tickDataFlux.blockFirst();
System.out.println("time: " + System.currentTimeMillis());
System.out.println(tickData.getPrice());
System.out.println(tickData.getQuantity());
System.out.println("=======================");
}
} catch (Exception e) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
testLogger.info(stringWriter.toString());
testLogger.info(e.getMessage());
}
}
Would this work? Looks like it does reconnect after wifi disconnection. I just don't know if it will work after 24h. I heard binance would drop connection after 24h?
from reactive-crypto.
Related Issues (20)
- Add new exchange coinall
- kraken orderbook stream synchronization error
- New Exchange Bhex
- New Exchange Bitz
- could not get maven resources from jitpack maven repository HOT 5
- What is the best way to get continuous tick data? HOT 1
- Add the dependency fails (Gradle builder) HOT 2
- BinanceWebsocketClient inheritance / unsubscribe from stream websocket HOT 3
- I am noob in as an android developer so please let me know how I can implement it in an android app?
- New exchange gate.io
- New exchange idax
- Publish to Maven Central
- New Exchange Bitmax
- New exchange coineal
- Bithumb multiple pair subscribe issue
- OrderBook synchronization fails on reconnection
- New exchange bitstamp
- Coineal open order error
- Okex Korea ws client doean't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactive-crypto.