diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index f05cc0268..5fa17be07 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -295,4 +295,11 @@ public interface BinanceApiRestClient { * @param listenKey listen key that identifies a data stream */ void closeUserDataStream(String listenKey); + + + /** + * Call to allow the client to shutdown cleanly instead of + * waiting for connection timeouts. + */ + void shutdown(); } diff --git a/src/main/java/com/binance/api/client/domain/general/RateLimitType.java b/src/main/java/com/binance/api/client/domain/general/RateLimitType.java index 25775dab5..fb5ee0e89 100755 --- a/src/main/java/com/binance/api/client/domain/general/RateLimitType.java +++ b/src/main/java/com/binance/api/client/domain/general/RateLimitType.java @@ -8,5 +8,6 @@ @JsonIgnoreProperties(ignoreUnknown = true) public enum RateLimitType { REQUEST_WEIGHT, - ORDERS + ORDERS, + RAW_REQUESTS } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index c1cd07f62..fdaa538e2 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -8,6 +8,8 @@ import com.binance.api.client.domain.general.Asset; import com.binance.api.client.domain.general.ExchangeInfo; import com.binance.api.client.domain.market.*; + +import okhttp3.OkHttpClient; import retrofit2.Call; import java.util.List; @@ -223,4 +225,12 @@ public void keepAliveUserDataStream(String listenKey) { public void closeUserDataStream(String listenKey) { executeSync(binanceApiService.closeAliveUserDataStream(listenKey)); } + + + // Close and remove all idle connections in the pool + @Override + public void shutdown() { + OkHttpClient okHttpClient = BinanceApiServiceGenerator.getSharedClient(); + okHttpClient.connectionPool().evictAll(); + } }