Skip to content

Commit d873536

Browse files
committed
Fix shared handler disposal
1 parent 5582a25 commit d873536

5 files changed

Lines changed: 21 additions & 9 deletions

File tree

Source/Singulink.Net.Http.Api.Client.SignalR/Singulink.Net.Http.Api.Client.SignalR.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net10.0</TargetFramework>
44

5-
<Version>1.10.1</Version>
5+
<Version>1.10.2</Version>
66
<Description>SignalR client library for the Singulink HTTP API Toolkit.</Description>
77
<PackageTags>HTTP; API; Client; SignalR;</PackageTags>
88
</PropertyGroup>

Source/Singulink.Net.Http.Api.Client/ApiClientBase.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ public abstract class ApiClientBase
3030

3131
private const int DefaultHttpClientRefreshDnsTimeout = 120 * 1000;
3232

33-
internal static readonly HttpMessageHandler? HttpMessageHandler = OperatingSystem.IsBrowser() ? null : new SocketsHttpHandler {
34-
PooledConnectionLifetime = TimeSpan.FromMilliseconds(DefaultHttpClientRefreshDnsTimeout),
35-
UseCookies = false,
36-
};
33+
internal static readonly HttpMessageHandler? HttpMessageHandler = OperatingSystem.IsBrowser() ? null : new SharedApiSocketsHttpHandler();
3734

3835
private static readonly HttpClient _httpClient = HttpMessageHandler is not null ? new HttpClient(HttpMessageHandler) : new HttpClient();
3936

@@ -485,4 +482,19 @@ private sealed class SessionState
485482

486483
public Action<string?>? ChangedCallback { get; set; }
487484
}
485+
486+
private class SharedApiSocketsHttpHandler : DelegatingHandler
487+
{
488+
public SharedApiSocketsHttpHandler()
489+
: base(new SocketsHttpHandler {
490+
PooledConnectionLifetime = TimeSpan.FromMilliseconds(DefaultHttpClientRefreshDnsTimeout),
491+
UseCookies = false,
492+
}) { }
493+
494+
protected override void Dispose(bool disposing)
495+
{
496+
// Do not dispose the inner handler
497+
base.Dispose(false);
498+
}
499+
}
488500
}

Source/Singulink.Net.Http.Api.Client/Singulink.Net.Http.Api.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>net10.0</TargetFramework>
44

5-
<Version>1.10.1</Version>
5+
<Version>1.10.2</Version>
66
<Description>API client library for the Singulink HTTP API Tookit.</Description>
77
<PackageTags>HTTP; API; Client;</PackageTags>
88
</PropertyGroup>

Source/Singulink.Net.Http.Api.Service/Singulink.Net.Http.Api.Service.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>net10.0</TargetFramework>
44
<OutputType>Library</OutputType>
55

6-
<Version>1.10.1</Version>
6+
<Version>1.10.2</Version>
77
<Description>ASP.NET API service library for the Singulink HTTP API Tookit.</Description>
88
<PackageTags>HTTP; API; Service; Server; Middleware;</PackageTags>
99
</PropertyGroup>

Source/Singulink.Net.Http.Api/Singulink.Net.Http.Api.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>net10.0</TargetFramework>
44

5-
<Version>1.10.1</Version>
5+
<Version>1.10.2</Version>
66
<Description>Shared client/service library for the Singulink HTTP API Toolkit.</Description>
77
</PropertyGroup>
88
</Project>

0 commit comments

Comments
 (0)