【问题标题】:Unable to access .Net App deployed in Heroku docker无法访问部署在 Heroku docker 中的 .Net 应用程序
【发布时间】:2023-01-22 22:29:54
【问题描述】:

我在 Heroku docker 上部署了 .NET 应用程序 部署顺利,没有错误 但是当我尝试打开应用程序时出现错误

尝试了一些东西,比如创建了名为 PORT 的 VAR 并给出了 5000 的值不锻炼

2023-01-22T12:30:50.674761+00:00 heroku[web.1]: Starting process with command `dotnet ./Muapp.dll --urls\=http://\*:5000`
2023-01-22T12:30:51.685276+00:00 app[web.1]: Welcome to Muapp!
2023-01-22T12:30:51.685567+00:00 app[web.1]:
2023-01-22T12:30:51.685571+00:00 app[web.1]:
2023-01-22T12:30:51.909353+00:00 app[web.1]: warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
2023-01-22T12:30:51.909375+00:00 app[web.1]: Storing keys in a directory '/app/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
2023-01-22T12:30:51.928587+00:00 app[web.1]: warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
2023-01-22T12:30:51.928590+00:00 app[web.1]: No XML encryptor configured. Key {f5035bc0-d6dd-402b-92f8-51341dd3511a} may be persisted to storage in unencrypted form.
2023-01-22T12:30:54.638199+00:00 app[web.1]: info: Microsoft.Hosting.Lifetime[14]
2023-01-22T12:30:54.638211+00:00 app[web.1]: Now listening on: http://[::]:5000
2023-01-22T12:30:54.642119+00:00 app[web.1]: info: Microsoft.Hosting.Lifetime[0]
2023-01-22T12:30:54.642121+00:00 app[web.1]: Application started. Press Ctrl+C to shut down.
2023-01-22T12:30:54.642714+00:00 app[web.1]: info: Microsoft.Hosting.Lifetime[0]
2023-01-22T12:30:54.642715+00:00 app[web.1]: Hosting environment: Production
2023-01-22T12:30:54.642715+00:00 app[web.1]: info: Microsoft.Hosting.Lifetime[0]
2023-01-22T12:30:54.642716+00:00 app[web.1]: Content root path: /app
2023-01-22T12:31:50.857290+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2023-01-22T12:31:50.888117+00:00 heroku[web.1]: Stopping process with SIGKILL
2023-01-22T12:31:51.047126+00:00 heroku[web.1]: Process exited with status 137
2023-01-22T12:31:51.113768+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-22T13:53:20.502985+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=oby.herokuapp.com request_id=6e089f4e-52e2-4c32-b28f-efc7999777ac fwd="104.28.255.112" dyno= connect= service= status=503 bytes= protocol=https
2023-01-22T13:53:22.376963+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=oby.herokuapp.com request_id=824189c7-7244-4070-bccb-7af1b4584e78 fwd="104.28.255.112" dyno= connect= service= status=503 bytes= protocol=https
2023-01-22T13:53:27.109966+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=oby.herokuapp.com request_id=eb7e2b1b-37d4-471c-9514-43da912b827d fwd="104.28.255.112" dyno= connect= service= status=503 bytes= protocol=http
2023-01-22T13:53:28.779659+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=oby.herokuapp.com request_id=6c5c88ed-ac9a-4e70-b422-d0bf294baeb4 fwd="104.28.255.112" dyno= connect= service= status=503 bytes= protocol=http

【问题讨论】:

    标签: docker asp.net-core heroku


    【解决方案1】:

    Heroku 会为您分配一个它希望您监听的端口。该端口在名为 PORT 的环境变量中传递给您。所以你不能决定你想在端口 5000 上监听,因为它很可能不是 Heroku 分配给你的端口。

    当 Heroku 发现您没有绑定到分配的端口时,它会杀死您的容器。

    要绑定到正确的端口,请将启动命令更改为

    dotnet ./Muapp.dll --urls=http://*:${PORT}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 1970-01-01
      • 2021-10-31
      • 1970-01-01
      • 2020-04-07
      • 2020-02-24
      • 2013-07-29
      相关资源
      最近更新 更多