Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

<artifactId>binance-common</artifactId>
<name>common</name>
<version>2.1.1</version>
<version>2.2.1</version>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public interface ConnectionInterface {
void setLogonMethods(List<String> logonMethods);

void setLogoutMethods(List<String> logoutMethods);

void stop() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketListener;
Expand Down Expand Up @@ -92,6 +93,8 @@ public class ConnectionWrapper implements WebSocketListener, ConnectionInterface

private List<BlockingQueue<String>> streamQueues = new ArrayList<>();

private Timer timer;

public ConnectionWrapper(WebSocketClientConfiguration configuration, Gson gson) {
this(configuration, null, gson);
}
Expand Down Expand Up @@ -160,8 +163,8 @@ public ConnectionWrapper(
}

Integer reconnectAfter = configuration.getReconnectIntervalTime();
new Timer()
.scheduleAtFixedRate(
this.timer = new Timer();
this.timer.scheduleAtFixedRate(
new TimerTask() {
@Override
public void run() {
Expand Down Expand Up @@ -221,6 +224,7 @@ public void connect(Consumer<Session> customCallback)
CompletableFuture<Session> clientSessionPromise =
webSocketClient.connect(this, serverURI, clientUpgradeRequest);
Session session = clientSessionPromise.join();

if (callback != null) {
callback.accept(session);
}
Expand Down Expand Up @@ -501,6 +505,7 @@ protected void afterConnect(Session session) {
if (this.oldSession != null) {
this.oldSession.close(StatusCode.NORMAL, "close after reconnect", WriteCallback.NOOP);
}
canReconnect = true;
setReady(true);
}

Expand Down Expand Up @@ -548,7 +553,17 @@ public URI getUri(String uri) throws URISyntaxException {
public void disconnect() {
if (this.session != null) {
this.session.disconnect();
}
setReady(false);
canReconnect = false;
}

public void stop() throws Exception {
if (this.webSocketClient != null) {
setReady(false);
canReconnect = false;
timer.cancel();
webSocketClient.stop();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,12 @@ public void setLogoutMethods(List<String> logoutMethods) {
public boolean isConnected() {
return isConnected;
}

@Override
public void stop() throws Exception {
for (ConnectionWrapper connectionWrapper : connectionList) {
connectionWrapper.stop();
}
isConnected = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ Map<String, StreamBlockingQueue<String>> subscribe(
boolean isConnected();

void setUserAgent(String userAgent);

void stop() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,12 @@ public void setUserAgent(String userAgent) {
public boolean isConnected() {
return isConnected;
}

@Override
public void stop() throws Exception {
for (ConnectionWrapper connectionWrapper : connectionList) {
connectionWrapper.stop();
}
isConnected = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void onWebSocketText(String message) {

protected void beforeConnect() {
// no session, so this is not a reconnect
if (this.session == null) {
if (this.session == null || !this.session.isOpen()) {
return;
}
RequestWrapperDTO<Object, HashSet<String>> listSubscriptions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ With the transition to a modularized structure, the Binance Connector has been s
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-derivatives-trading-coin-futures</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions clients/derivatives-trading-coin-futures/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>binance-derivatives-trading-coin-futures</artifactId>
<name>derivatives-trading-coin-futures</name>
<version>4.0.0</version>
<version>4.0.1</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-common</artifactId>
<version>2.1.1</version>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ With the transition to a modularized structure, the Binance Connector has been s
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-derivatives-trading-options</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions clients/derivatives-trading-options/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>binance-derivatives-trading-options</artifactId>
<name>derivatives-trading-options</name>
<version>4.0.0</version>
<version>4.0.1</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-common</artifactId>
<version>2.1.1</version>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ With the transition to a modularized structure, the Binance Connector has been s
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-derivatives-trading-portfolio-margin-pro</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions clients/derivatives-trading-portfolio-margin-pro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>binance-derivatives-trading-portfolio-margin-pro</artifactId>
<name>derivatives-trading-portfolio-margin-pro</name>
<version>4.0.0</version>
<version>4.0.1</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-common</artifactId>
<version>2.1.1</version>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ With the transition to a modularized structure, the Binance Connector has been s
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-derivatives-trading-portfolio-margin</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions clients/derivatives-trading-portfolio-margin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>binance-derivatives-trading-portfolio-margin</artifactId>
<name>derivatives-trading-portfolio-margin</name>
<version>3.0.0</version>
<version>3.0.1</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-common</artifactId>
<version>2.0.1</version>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ With the transition to a modularized structure, the Binance Connector has been s
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-derivatives-trading-usds-futures</artifactId>
<version>6.0.0</version>
<version>6.0.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions clients/derivatives-trading-usds-futures/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>binance-derivatives-trading-usds-futures</artifactId>
<name>derivatives-trading-usds-futures</name>
<version>6.0.0</version>
<version>6.0.1</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-common</artifactId>
<version>2.1.1</version>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion clients/spot/docs/rest-api/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ With the transition to a modularized structure, the Binance Connector has been s
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-spot</artifactId>
<version>7.0.0</version>
<version>7.0.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions clients/spot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>binance-spot</artifactId>
<name>spot</name>
<version>7.0.0</version>
<version>7.0.1</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-common</artifactId>
<version>2.1.1</version>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
Loading