我正在尝试在 heroku 上部署我的 Node 应用程序。
这个应用程序在本地运行良好,并在 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 工具显示了一些非常难读的东西...零换行符。
最佳答案
1
Heroku 不支持 websockets,所以尝试关闭它
// 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 - 是错误 H14(没有网络进程在运行)
尝试添加具有以下内容的 Procfile:
web:node server.js
关于node.js - Node.app - 在本地运行,正确部署但无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18654897/