use*_*686 5 iis iis-10 kestrel-http-server asp.net-core
我正面临着IIS + Kestrel托管asp.net核心应用程序(web api)的问题.
有时响应延迟约为5秒.在这种情况下,Chrome显示"GET net :: ERR_CONNECTION_TIMED_OUT"(但Firefox等待响应)
它只发生在IIS上,如果我在Visual Studio Code中本地运行它可以正常工作(至少我没有发现任何"冻结").
服务器端的应用程序日志中有一些信息.对于成功的请求,它看起来像:
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
Run Code Online (Sandbox Code Playgroud)
对于失败的看起来像:
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
Run Code Online (Sandbox Code Playgroud)
该应用程序的应用程序池设置为没有托管代码.
Web.config包含:
<?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>
Run Code Online (Sandbox Code Playgroud)
可能是这种奇怪行为的原因是什么?
PS
更新:
我为记录设置了"跟踪"级别,没有看到任何关于"损坏"请求的日志,只看到之前的请求.还看了一下chrome dev的工具"网络"选项卡,它有:
Request Headers
Provisional headers are shown
Access-Control-Request-Headers:access-control-allow-origin,authorization
Access-Control-Request-Method:GET
Run Code Online (Sandbox Code Playgroud)
更新:
我不知道为什么,但即使在像CSS这样的静态内容上它也开始出现自发错误.
另外我忘了注意我在asp.net web api 2(不是核心)上有相同的功能 - 它在同一台服务器上工作正常.在慢速请求之前在日志中创建此类信息:
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.
Run Code Online (Sandbox Code Playgroud)
更新:
IIS日志(内部inetpub/logs)中没有关于"损坏"请求的任何消息.只是关于上次成功请求 - 响应的信息.似乎IIS根本不处理请求.是否可能(我在IIS设置和配置方面没有经验)?
还尝试使用stub - empty .net核心应用程序而不是我的.结果是一样的.从我的结论来看,问题不在我的应用程序中
| 归档时间: |
|
| 查看次数: |
2720 次 |
| 最近记录: |