【问题标题】:Node.app - runs locally, deploys correctly but fails to workNode.app - 在本地运行,正确部署但无法工作
【发布时间】:2013-09-06 09:51:04
【问题描述】:

我正在尝试在 heroku 上部署我的节点应用程序。

这个应用程序在本地运行良好,并且在 heroku 上被正确推送。

但是,每当我尝试访问该 URL 时,浏览器都会显示:

An error occurred in the application and your page could not be served. Please try again       in a few moments.
If you are the application owner, check your logs for details

起初,我以为那是因为我没有注意我正在侦听的端口(我不太了解 Heroku 的处理方式以及端口是否重要),所以我复制了与他们在他们的开始...

    port = process.env.PORT || 5000;

server.listen(port, function() {
console.log("Listening on " + port);
});

我的 package.json 非常基础:

   {

"name":"Radiorev",
"version":"0.0.1",
"dependencies":{

    "express":"3.3.5",
    "socket.io":"0.9.16"
}
  }

救命!

顺便说一句,当我输入 heroku log 时,我的 cmd 工具显示一些非常难以阅读的内容......零换行符。

【问题讨论】:

  • heroku logs --app {appname} 究竟输出了什么?

标签: node.js heroku deployment


【解决方案1】:

1

Heroku 不支持 websocket,因此请尝试将其关闭

// assuming io is the Socket.IO server object
io.configure(function () { 
  io.set("transports", ["xhr-polling"]); 
  io.set("polling duration", 10); 
});

根据Using Socket.IO with Node.js on Heroku

2

更新:H14 - 是Error H14 (No web processes running)

尝试添加具有以下内容的 Procfile:

web: node server.js

【讨论】:

  • 这看起来很有希望......但是,它仍然无法正常工作:(我在执行 Heroku 日志时遇到 H14 错误
  • heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=radiorev.herokuapp.com fwd="88.181.11.146" dyno =连接=服务=状态=503字节=
  • 我已经添加了个人资料。我按照heroku网站上的所有步骤进行操作。我的应用名为 app.js,所以我添加了:web: node app.js
  • @user2249582 只是为了澄清它的 Procfile,而不是 Profile
【解决方案2】:

问题可能是您将网络测功机缩放到 0,因此没有人运行服务器。尝试运行:

heroku ps:scale web=1

(参考:https://devcenter.heroku.com/articles/error-codes#h14-no-web-dynos-running

【讨论】:

  • 谢谢 Vitor,这个对我有用。运行 scale web 后运行 heroku ps
  • 我很高兴它有帮助 :-)
猜你喜欢
  • 2021-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-21
  • 2016-12-05
  • 1970-01-01
  • 2014-05-27
  • 2020-12-28
相关资源
最近更新 更多