Asp.NET Core Hosting on IIS + Kestrel: random slow response

I'm having a problem with IIS + Kestrel hosting my main asp.net application (web api).

Sometimes the response delay is about 5 seconds. In this case, Chrome shows "GET net :: ERR_CONNECTION_TIMED_OUT" (but Firefox is waiting for a response)

This only happens in IIS, if I run it locally in Visual Studio Code it works fine (at least I didn't notice any hangs).

There is some information from the server side application log. For a successful request, it looks like this:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 OPTIONS http://
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 0.2813ms 204 
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://
info: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[2]
      Successfully validated the token.
info: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[3]
      HttpContext.User merged via AutomaticAuthentication from authenticationScheme: Bearer.
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[1]
      Authorization was successful for user: admin.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method <method-name> with arguments <args> - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutor[1]
      Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action <method-name> in 41.9809ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 42.6694ms 200 application/json; charset=utf-8

      

for unsuccessful ones looks like this:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 OPTIONS http://
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 0.3408ms 204 

      

The app pool for this app is configured with no managed code.

Web.config contains:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\app.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="app-release" />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

      

What could be the reason for this strange behavior?

PS

  • IIS version - 10
  • netcoreapp - 1.1 (common "Microsoft.AspNetCore". libraries - 1.1.1)

Update:

I set the Trace level for logging and did not see any logs about the "corrupted" query, only the queries before. Also looked at the chrome dev tools "network" tab and there is:

Request Headers
Provisional headers are shown
Access-Control-Request-Headers:access-control-allow-origin,authorization
Access-Control-Request-Method:GET

      

Update:

I have no idea why, but it started to err spontaneously even with static content like css.

Also I forgot to note that I have the same functionality on asp.net web api 2 (not core) - and it works fine on a single server. Created information like this in the log prior to the slow request:

dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HL3SC4O1J78T" stopped.
dbug: Microsoft.AspNetCore.Server.Kestrel[8]
      Connection id "0HL3SC4O1J78S" sent FIN with status "0".
dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HL3SC4O1J78S" stopped.
dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HL3SC4O1J78R" stopped.
dbug: Microsoft.AspNetCore.Server.Kestrel[8]
      Connection id "0HL3SC4O1J78V" sent FIN with status "0".
dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HL3SC4O1J78V" stopped.

      

Update:

There inetpub/logs

are no messages in the IIS log (inside ) about a "bad" request. Just information about the last successful request-response. It looks like IIS is not being processed at all. Is it possible (I have no experience in setting up and configuring IIS)?

Also tried to use the unfilled core .net instead of mine. The result is the same. From which I conclude that the problem is not in my application

+3


source to share





All Articles