diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index cafaa72..e156742 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Set GitHub package source
run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json"
- name: Restore dependencies
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 3801845..d751ddb 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Set GitHub package source
run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json"
- name: Restore dependencies
diff --git a/CoinEx.Net.UnitTests/CoinEx.Net.UnitTests.csproj b/CoinEx.Net.UnitTests/CoinEx.Net.UnitTests.csproj
index 168fe89..3aa0630 100644
--- a/CoinEx.Net.UnitTests/CoinEx.Net.UnitTests.csproj
+++ b/CoinEx.Net.UnitTests/CoinEx.Net.UnitTests.csproj
@@ -2,7 +2,7 @@
Library
- net8.0
+ net9.0
diff --git a/CoinEx.Net/Clients/CoinExRestClient.cs b/CoinEx.Net/Clients/CoinExRestClient.cs
index 06cf80b..f605c6d 100644
--- a/CoinEx.Net/Clients/CoinExRestClient.cs
+++ b/CoinEx.Net/Clients/CoinExRestClient.cs
@@ -8,6 +8,7 @@
using CoinEx.Net.Interfaces.Clients.FuturesApi;
using CoinEx.Net.Clients.FuturesApi;
using Microsoft.Extensions.Options;
+using CryptoExchange.Net.Objects.Options;
namespace CoinEx.Net.Clients
{
@@ -51,6 +52,14 @@ public CoinExRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, I
#endregion
#region methods
+ ///
+ public void SetOptions(UpdateOptions options)
+ {
+ FuturesApi.SetOptions(options);
+ SpotApi.SetOptions(options);
+ SpotApiV2.SetOptions(options);
+ }
+
///
/// Set the default options to be used when creating new clients
///
diff --git a/CoinEx.Net/Clients/CoinExSocketClient.cs b/CoinEx.Net/Clients/CoinExSocketClient.cs
index 2c80004..5c76cb2 100644
--- a/CoinEx.Net/Clients/CoinExSocketClient.cs
+++ b/CoinEx.Net/Clients/CoinExSocketClient.cs
@@ -7,6 +7,7 @@
using CoinEx.Net.Interfaces.Clients.FuturesApi;
using CoinEx.Net.Clients.FuturesApi;
using Microsoft.Extensions.Options;
+using CryptoExchange.Net.Objects.Options;
namespace CoinEx.Net.Clients
{
@@ -59,6 +60,14 @@ public static void SetDefaultOptions(Action optionsDelegate
CoinExSocketOptions.Default = ApplyOptionsDelegate(optionsDelegate);
}
+ ///
+ public void SetOptions(UpdateOptions options)
+ {
+ FuturesApi.SetOptions(options);
+ SpotApi.SetOptions(options);
+ SpotApiV2.SetOptions(options);
+ }
+
///
public void SetApiCredentials(ApiCredentials credentials)
{
diff --git a/CoinEx.Net/Clients/FuturesApi/CoinExSocketClientFuturesApi.cs b/CoinEx.Net/Clients/FuturesApi/CoinExSocketClientFuturesApi.cs
index 086d8eb..05de106 100644
--- a/CoinEx.Net/Clients/FuturesApi/CoinExSocketClientFuturesApi.cs
+++ b/CoinEx.Net/Clients/FuturesApi/CoinExSocketClientFuturesApi.cs
@@ -43,7 +43,19 @@ internal partial class CoinExSocketClientFuturesApi : SocketApiClient, ICoinExSo
internal CoinExSocketClientFuturesApi(ILogger logger, CoinExSocketOptions options)
: base(logger, options.Environment.SocketBaseAddress, options, options.FuturesOptions)
{
- RegisterPeriodicQuery("Ping", TimeSpan.FromMinutes(1), q => (new CoinExQuery("server.ping", new Dictionary())), null);
+ RegisterPeriodicQuery(
+ "Ping",
+ TimeSpan.FromSeconds(30),
+ q => new CoinExQuery("server.ping", new Dictionary()) { RequestTimeout = TimeSpan.FromSeconds(5) },
+ (connection, result) =>
+ {
+ if (result.Error?.Message.Equals("Query timeout") == true)
+ {
+ // Ping timeout, reconnect
+ _logger.LogWarning("[Sckt {SocketId}] Ping response timeout, reconnecting", connection.SocketId);
+ _ = connection.TriggerReconnectAsync();
+ }
+ });
}
#endregion
diff --git a/CoinEx.Net/Clients/SpotApiV2/CoinExSocketClientSpotApi.cs b/CoinEx.Net/Clients/SpotApiV2/CoinExSocketClientSpotApi.cs
index 90296b1..dc30489 100644
--- a/CoinEx.Net/Clients/SpotApiV2/CoinExSocketClientSpotApi.cs
+++ b/CoinEx.Net/Clients/SpotApiV2/CoinExSocketClientSpotApi.cs
@@ -43,7 +43,19 @@ internal partial class CoinExSocketClientSpotApi : SocketApiClient, ICoinExSocke
internal CoinExSocketClientSpotApi(ILogger logger, CoinExSocketOptions options)
: base(logger, options.Environment.SocketBaseAddress, options, options.SpotOptions)
{
- RegisterPeriodicQuery("Ping", TimeSpan.FromMinutes(1), q => (new CoinExQuery("server.ping", new Dictionary())), null);
+ RegisterPeriodicQuery(
+ "Ping",
+ TimeSpan.FromSeconds(30),
+ q => new CoinExQuery("server.ping", new Dictionary()) { RequestTimeout = TimeSpan.FromSeconds(5) },
+ (connection, result) =>
+ {
+ if (result.Error?.Message.Equals("Query timeout") == true)
+ {
+ // Ping timeout, reconnect
+ _logger.LogWarning("[Sckt {SocketId}] Ping response timeout, reconnecting", connection.SocketId);
+ _ = connection.TriggerReconnectAsync();
+ }
+ });
}
#endregion
diff --git a/CoinEx.Net/CoinEx.Net.csproj b/CoinEx.Net/CoinEx.Net.csproj
index 9a4ebf2..12c7d50 100644
--- a/CoinEx.Net/CoinEx.Net.csproj
+++ b/CoinEx.Net/CoinEx.Net.csproj
@@ -48,8 +48,8 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/CoinEx.Net/CoinEx.Net.xml b/CoinEx.Net/CoinEx.Net.xml
index b7b879a..b595bd8 100644
--- a/CoinEx.Net/CoinEx.Net.xml
+++ b/CoinEx.Net/CoinEx.Net.xml
@@ -30,6 +30,9 @@
The logger factory
Http client for this client
+
+
+
Set the default options to be used when creating new clients
@@ -70,6 +73,9 @@
Option configuration delegate
+
+
+
@@ -2444,6 +2450,12 @@
Futures V2 API endpoints
+
+
+ Update specific options
+
+ Options to update. Only specific options are changable after the client has been created
+
Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
@@ -2470,6 +2482,12 @@
DEPRECATED FROM 2024/09/25, USE SpotApiV2 INSTEAD
+
+
+ Update specific options
+
+ Options to update. Only specific options are changable after the client has been created
+
Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
diff --git a/CoinEx.Net/ExtensionMethods/ServiceCollectionExtensions.cs b/CoinEx.Net/ExtensionMethods/ServiceCollectionExtensions.cs
index 903e267..309b542 100644
--- a/CoinEx.Net/ExtensionMethods/ServiceCollectionExtensions.cs
+++ b/CoinEx.Net/ExtensionMethods/ServiceCollectionExtensions.cs
@@ -113,6 +113,7 @@ private static IServiceCollection AddCoinExCore(
try
{
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
+ handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
}
catch (PlatformNotSupportedException)
{ }
diff --git a/CoinEx.Net/Interfaces/Clients/ICoinExRestClient.cs b/CoinEx.Net/Interfaces/Clients/ICoinExRestClient.cs
index 3a872d1..4cfc490 100644
--- a/CoinEx.Net/Interfaces/Clients/ICoinExRestClient.cs
+++ b/CoinEx.Net/Interfaces/Clients/ICoinExRestClient.cs
@@ -1,6 +1,7 @@
using CoinEx.Net.Interfaces.Clients.FuturesApi;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Interfaces;
+using CryptoExchange.Net.Objects.Options;
namespace CoinEx.Net.Interfaces.Clients
{
@@ -22,6 +23,12 @@ public interface ICoinExRestClient : IRestClient
///
ICoinExRestClientFuturesApi FuturesApi { get; }
+ ///
+ /// Update specific options
+ ///
+ /// Options to update. Only specific options are changable after the client has been created
+ void SetOptions(UpdateOptions options);
+
///
/// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
///
diff --git a/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs b/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs
index e7de576..e1b81e3 100644
--- a/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs
+++ b/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs
@@ -1,6 +1,7 @@
using CoinEx.Net.Interfaces.Clients.FuturesApi;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Interfaces;
+using CryptoExchange.Net.Objects.Options;
namespace CoinEx.Net.Interfaces.Clients
{
@@ -22,6 +23,12 @@ public interface ICoinExSocketClient : ISocketClient
///
public SpotApiV1.ICoinExSocketClientSpotApi SpotApi { get; }
+ ///
+ /// Update specific options
+ ///
+ /// Options to update. Only specific options are changable after the client has been created
+ void SetOptions(UpdateOptions options);
+
///
/// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
///