2

我正在尝试在 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 日志时,我的 cmd 工具显示一些非常难以理解的内容......零换行符。

4

2 回答 2

5

1

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

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

根据在 Heroku 上将 Socket.IO 与 Node.js 结合使用

2

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

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

web: node server.js

于 2013-09-06T10:38:56.700 回答
3

问题可能是您将 Web dynos 缩放到 0,因此没有人运行服务器。尝试运行:

heroku ps:scale web=1

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

于 2013-12-09T21:40:02.653 回答