Repository navigation
Closed
Description
Description
ASP.NET 5 -- Impersonation -- A call to WSALookupServiceEnd was made while this call was still processing
As a note, this does work locally with IIS Express. This is only happening when the code is deployed running on IIS Windows Server 2012.
Configuration
- Which version of .NET is the code running on?
.NET 5 - What OS and version, and what distro if applicable?
Windows Server 2012 -- IIS 11 - What is the architecture (x64, x86, ARM, ARM64)?
x64
Regression?
Doesn't work in .NET Core 3.1 or in .NET 5
Code
public async Task<Results<string>> SendRequest(HttpRequestMessage request)
{
try
{
WindowsIdentity identity = (WindowsIdentity)_httpContextAccessor.HttpContext.User.Identity;
return await WindowsIdentity.RunImpersonated(identity.AccessToken, async () =>
{
using (var httpResp = await _client.SendAsync(request))
{
if (httpResp.IsSuccessStatusCode)
{
return (await httpResp.Content.ReadAsStringAsync()).AsResultValue();
}
else
{
var content = await httpResp.Content.ReadAsStringAsync();
var result = Utilities.Deserialize<Error>(content.AsResultValue<string>());
if (result.IsValue && result.Value.Code != null)
{
return Results<string>.AsResultError(new ErrorValue((int)result.Value.Code, result.Value.Message));
}
var phrase = !string.IsNullOrEmpty(httpResp.ReasonPhrase) ? $"httpResp.ReasonPhrase {content}" : $"unable to complete request due to {content}";
return Results<string>.AsResultError(new ErrorValue((int)httpResp.StatusCode, phrase));
}
}
});
}
catch (Exception ex)
{
return ex.AsResultError<string>();
}
}Error
2020-11-14 11:23:34.854 -05:00 [ERR] Status Code 500 - an internal error has occurred
2020-11-14 11:23:34.854 -05:00 [ERR] A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled. (___.___.com:443)
2020-11-14 11:23:34.855 -05:00 [ERR] at System.Net.Http.ConnectHelper.ConnectAsync(Func`3 callback, DnsEndPoint endPoint, HttpRequestMessage requestMessage, 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.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, Boolean async, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
at ApiClient.<>c__DisplayClass3_0.<<SendRequest>b__0>d.MoveNext() in
--- End of stack trace from previous location ---
As an additional note, I did try setting DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER = 0 (.net core 3.1 and .net 5) without any success.
I have tried running as the system administrator as well and receiving the same error.
Activity
Dotnet-GitSync-Bot commentedon Nov 24, 2020
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
jkotas commentedon Nov 24, 2020
Dup of #29935 ? cc @karelz
BChip commentedon Nov 24, 2020
@jkotas I thought it might be, but I don't see that issue referencing the same error log I am experiencing:
A call to WSALookupServiceEnd was made while this call was still processing-- I definitely think they are relatable though.karelz commentedon Dec 17, 2020
Triage: Looks like a regression -- @wfurt can you check if it is a dupe of #29935 or if it is another regression, potentially worth servicing.
wfurt commentedon Jan 22, 2021
I'm running into this on Windows 8 while working on new test for #29935. So it is probably same underlying issue (or related) but the manifestation is different. (so the fix will likely not work)
karelz commentedon Feb 11, 2021
Fixed in 6.0 (master) in PR #47435 and in 5.0.4 in PR #47657