kucoin / kucoin-futures-java-sdk Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
It is common practice to have some kind of logging to be able to debug the communication. This will require to introduce a logging interceptor right after the actually used AuthenticationInterceptor. However in order to not close the underlying buffers, it is good to upgrade retrofit2 version (currently 2.9.0), so that response.body().source().peek() function will be introduced in class RealBufferedSource. This function allows to clone the source and that way preserve the source for later use yet be able to log the response body at the same time.
Although I applied the solution, Kucoin/kucoin-java-sdk#41, while socket running gets the exception below. The socket can work for a maximum of 1 day without any errors. Are there any ways to solve this problem or auto reconnect again when the exception occurs?
2021-05-29 03:14:24.151 ERROR 13061 --- [.kucoin.com/...] k.f.c.w.l.KucoinFuturesWebsocketListener : Error on private socket
javax.net.ssl.SSLException: Connection reset
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:127) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:349) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:292) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:287) ~[na:na]
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:144) ~[na:na]
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1421) ~[na:na]
at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1386) ~[na:na]
at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:973) ~[na:na]
at okio.Okio$2.read(Okio.java:140) ~[okio-1.17.2.jar!/:na]
at okio.AsyncTimeout$2.read(AsyncTimeout.java:237) ~[okio-1.17.2.jar!/:na]
at okio.RealBufferedSource.request(RealBufferedSource.java:72) ~[okio-1.17.2.jar!/:na]
at okio.RealBufferedSource.require(RealBufferedSource.java:65) ~[okio-1.17.2.jar!/:na]
at okio.RealBufferedSource.readByte(RealBufferedSource.java:78) ~[okio-1.17.2.jar!/:na]
at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.java:117) ~[okhttp-3.14.9.jar!/:na]
at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:101) ~[okhttp-3.14.9.jar!/:na]
at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:273) ~[okhttp-3.14.9.jar!/:na]
at okhttp3.internal.ws.RealWebSocket$1.onResponse(RealWebSocket.java:209) ~[okhttp-3.14.9.jar!/:na]
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:174) ~[okhttp-3.14.9.jar!/:na]
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) ~[okhttp-3.14.9.jar!/:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Suppressed: java.net.SocketException: Broken pipe (Write failed)
at java.base/java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:na]
at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:110) ~[na:na]
at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:150) ~[na:na]
at java.base/sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:81) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:380) ~[na:na]
... 20 common frames omitted
Caused by: java.net.SocketException: Connection reset
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186) ~[na:na]
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140) ~[na:na]
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478) ~[na:na]
at java.base/sun.security.ssl.SSLSocketInputRecord.readFully(SSLSocketInputRecord.java:461) ~[na:na]
at java.base/sun.security.ssl.SSLSocketInputRecord.decodeInputRecord(SSLSocketInputRecord.java:243) ~[na:na]
at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:181) ~[na:na]
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:110) ~[na:na]
... 17 common frames omitted
how to use OCO in Futures api ?
Hi,
I encouter an issue when i call two times with different set of API KEY plug on 2 different account.
After some analyse, I found a not thread safe code in class com.kucoin.sdk.factory.RetrofitFactory.
The same instance will be return when an instance as already been generated.
The fix could be :
public class RetrofitFactory {
private static final Converter.Factory CONVERTER_FACTORY = JacksonConverterFactory.create(KucoinObjectMapper.INSTANCE);
public static Retrofit getPublicRetorfit(String baseUrl) {
return new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(CONVERTER_FACTORY)
.client(HttpClientFactory.getPublicClient())
.build();
}
public static Retrofit getAuthRetorfit(String baseUrl, String apiKey, String secret, String passPhrase, Integer apiKeyVersion) {
return new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(CONVERTER_FACTORY)
.client(HttpClientFactory.getAuthClient(apiKey, secret, passPhrase, apiKeyVersion))
.build();
}
}
In request to GET /api/v1/transaction-history you should be able to define parameter "forward", yet this is currently not true in the sdk.
Hot to add new Order with TP and SP in one request by java api in futures ??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.