-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
Using HttpClient, When attempting to make GET requests to a certain web address, the method occasionally fails with an error The SSL connection could not be established, see inner exception. where the inner exception says Exception of type 'System.Net.InternalException' was thrown. -2146892963. Occasionally is the key here - it sometimes "just works" (in the provided code below it should result in 503 Service Temporarily Unavailable when it works.)
Minimal reproducible code:
HttpClient client = new HttpClient();
await client.GetStringAsync("https://newbiepr.gitlab.io"); // Fails on this lineException details:
| HttpRequestException4 | ||||||||||||||||||||||
| The SSL connection could not be established, see inner exception. | ||||||||||||||||||||||
| Data |
| |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| HelpLink | null | |||||||||||||||||||||
| HResult | -2146233088 | |||||||||||||||||||||
| InnerException |
| |||||||||||||||||||||
| Message | The SSL connection could not be established, see inner exception. | |||||||||||||||||||||
| Source | System.Net.Http | |||||||||||||||||||||
| StackTrace | at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken) at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at UserQuery.Main(), line 2 | |||||||||||||||||||||
| StatusCode | null | |||||||||||||||||||||
Configuration
Windows version: Windows 10 Pro Insiders Preview Build 21364 (Dev ring), x64, Korean
.NET SDK used: 5.0.200-preview.21077.7
Regression?
As far as I can tell it can be reproduced on .NET Framework 4.8 that's installed on my Windows as well, albeit with a different error message:
| HttpRequestException4 | ||||||||||||||||||||||||||
| An error occurred while sending the request. | ||||||||||||||||||||||||||
| Data |
| |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| HelpLink | null | |||||||||||||||||||||||||
| HResult | -2146233088 | |||||||||||||||||||||||||
| InnerException |
| |||||||||||||||||||||||||
| Message | An error occurred while sending the request. | |||||||||||||||||||||||||
| Source | mscorlib | |||||||||||||||||||||||||
| StackTrace | 위치: System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 위치: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 위치: System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 위치: UserQuery.<RunUserAuthoredQuery>d__0.MoveNext() 파일 C:\Users\gotos\AppData\Local\Temp\LINQPad5\_tjauvduk\query_uwxuos.cs:줄 41 | |||||||||||||||||||||||||
Other information
As far as I can tell, I do not see any sort of similar errors showing up when I make the request with other tools such as curl or Edge browser.
Might be related: #44058 (although the issue was closed for insufficient info)
If you're having trouble reproducing the issue I am happy to provide packet captures for troubleshooting.