尝试打开应用程序时出现 Heroku 错误代码 H13
Heroku error code H13 when trying to open app
我尝试将我的 node.js 应用程序部署到 Heroku,在我尝试连接到它(打开应用程序)之前一切正常。
得到错误如下:
2021-02-18T00:16:03.975921+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=gtdb.herokuapp.com request_id=16579da6-aa8e-4184-8e1c-7ac9680d0078 fwd="-myipaddresswhichidontwanttoshare-" dyno=web.1 connect=0ms service=1ms status=503 bytes=0 protocol=https
我的代码:
const express = require("express");
const https = require("https");
app = express();
const options = {
key: fs.readFileSync("./server.key"),
cert: fs.readFileSync("./server.crt")
};
const server = https.createServer(options, app);
server.listen(process.env.PORT);
当然,我搜索了这个问题,一些网站说这可能是超时,他们的错误连接和服务时间长达 30000 毫秒,超时是完全合理的,但我离 30 秒还很远,所以我不知道知道这里的问题是什么。
该应用程序在抛出该错误后不会崩溃。
任何帮助深表感谢。提前致谢。
Heroku 服务器由其负载均衡器控制,负载均衡器终止 SSL 并在没有 SSL 的情况下将请求发送到您的服务器。
所以你应该在 Heroku 上使用 HTTP
服务器而不是 HTTPS
。
您可以使用此包 https://github.com/paulomcnally/node-heroku-ssl-redirect/ 将任何传入的 HTTP 流量从客户端重定向到 HTTPS。
我尝试将我的 node.js 应用程序部署到 Heroku,在我尝试连接到它(打开应用程序)之前一切正常。 得到错误如下:
2021-02-18T00:16:03.975921+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=gtdb.herokuapp.com request_id=16579da6-aa8e-4184-8e1c-7ac9680d0078 fwd="-myipaddresswhichidontwanttoshare-" dyno=web.1 connect=0ms service=1ms status=503 bytes=0 protocol=https
我的代码:
const express = require("express");
const https = require("https");
app = express();
const options = {
key: fs.readFileSync("./server.key"),
cert: fs.readFileSync("./server.crt")
};
const server = https.createServer(options, app);
server.listen(process.env.PORT);
当然,我搜索了这个问题,一些网站说这可能是超时,他们的错误连接和服务时间长达 30000 毫秒,超时是完全合理的,但我离 30 秒还很远,所以我不知道知道这里的问题是什么。 该应用程序在抛出该错误后不会崩溃。 任何帮助深表感谢。提前致谢。
Heroku 服务器由其负载均衡器控制,负载均衡器终止 SSL 并在没有 SSL 的情况下将请求发送到您的服务器。
所以你应该在 Heroku 上使用 HTTP
服务器而不是 HTTPS
。
您可以使用此包 https://github.com/paulomcnally/node-heroku-ssl-redirect/ 将任何传入的 HTTP 流量从客户端重定向到 HTTPS。