runtime: SocketException "Unknown error (0xffffffff)" at System.Net.Http.ConnectHelper.ConnectAsync
Type name: System.Net.Sockets.SocketException
.HResult = -2147467259
.Message = “Unknown error (0xffffffff)”
.NativeErrorCode = -1
.Source = “System.Private.CoreLib”
The stack trace for the outer exception:
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
We started receiving this error a few hours ago (after weeks / months of no problem), and a process restart was required to fix it. It occurred on every outbound HTTP request until the process was killed. Process memory use was not particularly high.
Azure App Service. Kudu versioning:

Other versions:
my\bin\folder> dotnet --version
2.2.102
From csproj:
<TargetFramework>netcoreapp2.1</TargetFramework>
I checked the TCP Connections diagnostics tool on Azure - there were only ~1000 connections being used (so I guess not port exhaustion?).
Interestingly - we’re using StackExchange.Redis and at the time of the first exception, I do see that there was a connection error with Redis too.
What can I do to assist? The problem occurred in production, and while I have app-level logging, but not too much else.
Edit: the issue just re-occurred on the same server, after the process restart
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 39 (15 by maintainers)
I have the similar issue running Lambda in AWS. The root cause is because I create HttpClient for every request. It was fixed by reusing one HttpClient instance. You may need to check your code if you create too many HttpClient instances.