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/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 6eff1a1..12c7d50 100644 --- a/CoinEx.Net/CoinEx.Net.csproj +++ b/CoinEx.Net/CoinEx.Net.csproj @@ -49,12 +49,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - \ No newline at end of file diff --git a/CoinEx.Net/CoinEx.Net.xml b/CoinEx.Net/CoinEx.Net.xml index 6a2733b..b595bd8 100644 --- a/CoinEx.Net/CoinEx.Net.xml +++ b/CoinEx.Net/CoinEx.Net.xml @@ -2454,7 +2454,7 @@ Update specific options - + Options to update. Only specific options are changable after the client has been created @@ -2486,7 +2486,7 @@ Update specific options - + Options to update. Only specific options are changable after the client has been created 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 e96143f..4cfc490 100644 --- a/CoinEx.Net/Interfaces/Clients/ICoinExRestClient.cs +++ b/CoinEx.Net/Interfaces/Clients/ICoinExRestClient.cs @@ -26,7 +26,7 @@ public interface ICoinExRestClient : IRestClient /// /// Update specific options /// - /// + /// Options to update. Only specific options are changable after the client has been created void SetOptions(UpdateOptions options); /// diff --git a/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs b/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs index 283edfd..e1b81e3 100644 --- a/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs +++ b/CoinEx.Net/Interfaces/Clients/ICoinExSocketClient.cs @@ -26,7 +26,7 @@ public interface ICoinExSocketClient : ISocketClient /// /// Update specific options /// - /// + /// Options to update. Only specific options are changable after the client has been created void SetOptions(UpdateOptions options); ///