【问题标题】:Asp Net Core 3 Sample with 503 Service Unavailable503 服务不可用的 Asp Net Core 3 示例
【发布时间】:2020-05-30 11:59:54
【问题描述】:

在 Visual Studio 中使用 react 和 .Net Core 3.0 或 3.1 创建新的 ASP.NET Core Web 应用程序并运行页面显示的应用程序时:

503 服务不可用

连接本地服务器失败

  • 我使用的是 Windows 10 Professional 和 Visual Studio 2019。
  • 在 IISExpress 和 kestrel 中运行时发生错误。
  • 在不同的机器上这工作正常。
  • 使用“Web 应用程序(模型-视图-控制器)”创建模板是可行的。
  • api 调用有效 (https://localhost:5001/WeatherForecast)。

我正在对从 AspNet Core 2.2 到 3.0 的项目中的迁移进行故障排除时出现相同的错误,我检查了模板项目是否可以工作,并发现该错误并非特定于迁移。找出模板不工作的原因可能会解决迁移错误。

编辑:

  • 禁用防火墙未解决问题。

这是尝试打开页面的调试日志:

dbug: Microsoft.AspNetCore.Server.Kestrel[39]
      Connection id "0HLTKHV201G3Q" accepted.
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
      Connection id "0HLTKHV201G3Q" started.
dbug: Microsoft.AspNetCore.Server.Kestrel[39]
      Connection id "0HLTKHV201G3R" accepted.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5000/
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
      Connection id "0HLTKHV201G3R" started.
trce: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[2]
      All hosts are allowed.
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[4]
      The request path / does not match a supported file type
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1000]
      No candidates found for the request path '/'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[2]
      Request did not match any endpoints
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 27.156ms 503 text/html; charset=UTF-8
dbug: Microsoft.AspNetCore.Server.Kestrel[10]
      Connection id "0HLTKHV201G3Q" disconnecting.
dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HLTKHV201G3Q" stopped.
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6]
      Connection id "0HLTKHV201G3Q" received FIN.
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7]
      Connection id "0HLTKHV201G3Q" sending FIN because: "The Socket transport's send loop completed gracefully."
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5000/favicon.ico
trce: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[2]
      All hosts are allowed.
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[5]
      The request path /favicon.ico does not match an existing file
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1000]
      No candidates found for the request path '/favicon.ico'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[2]
      Request did not match any endpoints
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 19.8075ms 503 text/html; charset=UTF-8
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6]
      Connection id "0HLTKHV201G3R" received FIN.
dbug: Microsoft.AspNetCore.Server.Kestrel[10]
      Connection id "0HLTKHV201G3R" disconnecting.
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7]
      Connection id "0HLTKHV201G3R" sending FIN because: "The client closed the connection."
dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HLTKHV201G3R" stopped.

【问题讨论】:

  • A 503 Service Unavailable Error是一个HTTP响应状态码,表示服务器暂时无法处理请求。这可能是由于服务器过载或停机维护。您可以参考airbrake.io/blog/http-errors/503-service-unavailable在服务器端进行故障排除。
  • 感谢您的参考,但仍然无法解决问题。禁用防火墙不起作用。提高了日志级别,但看不到 503 响应的原因。

标签: asp.net-core .net-core asp.net-core-3.0 asp.net-core-3.1


【解决方案1】:

发生这种情况是因为代理阻止了来自 .Net 主机的响应和角度请求。

在 AspNetCore 3.0 中,HttpClient 现在有一个从系统变量 HTTPS_PROXY、HTTP_PROXY 和 NO_PROXY 创建的默认代理。

NO_PROXY=localhost 添加到系统变量解决了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 2022-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    相关资源
    最近更新 更多