Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 502坏网关nginx谷歌应用程序引擎_Node.js_Google App Engine_Nginx_Heroku - Fatal编程技术网

Node.js 502坏网关nginx谷歌应用程序引擎

Node.js 502坏网关nginx谷歌应用程序引擎,node.js,google-app-engine,nginx,heroku,Node.js,Google App Engine,Nginx,Heroku,我正在使用express构建NodeJS应用程序以下是我的代码: var express = require('express'); var app = express(); var session = require('express-session'); var uuidv1 = require('uuid/v1'); require('dotenv').config(); var APIAI_TOKEN = process.env.APIAI_TOKEN; var APIAI_SESS

我正在使用express构建NodeJS应用程序以下是我的代码:

var express = require('express');
var app = express();
var session = require('express-session');
var uuidv1  = require('uuid/v1');
require('dotenv').config();

var APIAI_TOKEN = process.env.APIAI_TOKEN;
var APIAI_SESSION_ID = uuidv1();

app.use(express.static(__dirname + '/views')); // html
app.use(express.static(__dirname + '/public')); // js, css, images

var server = require('http').createServer(app);
var port = process.env.port || 3000;

server.listen(port, function() {
    console.log('Server listening at port: ', port);
    // console.log(APIAI_SESSION_ID);
    // console.log(APIAI_TOKEN);
});

app.use(session({
    genid: function(req) {
        return APIAI_SESSION_ID;
    },
    secret: 'secret',
    saveUninitialized: true,
    resave: true
}));

var io = require('socket.io')(server);

var apiai = require('apiai')(APIAI_TOKEN);
var rp = require('request-promise');

//#region Web UI

app.get('/', function(req, res) {
    res.sendFile('index.html');
});
我用node app启动我的应用程序,所有东西都在本地主机上完美运行,但当我将应用程序部署到Google app engine时,我得到一个502错误网关,当我检查日志时,它发生在
app.get()
方法。 我甚至还将它部署到Heroku服务器上,应用程序在同一点上崩溃。我的代码可能有什么问题? 以下是Heroku服务器的日志表单:

2017-11-01T16:35:57.528020+00:00 heroku[router]: at=error code=H10 

desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=d956df30-8352-4a54-80e6-2aa1fc96276b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:58.138751+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=96b2bf0d-df05-4d7e-9018-0b09e1dfa748 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-11-01T16:19:36.517868+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-11-01T16:19:36.513572+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-11-01T16:19:36.517927+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2017-11-01T16:19:36.584087+00:00 heroku[web.1]: Process exited with status 1
2017-11-01T16:19:36.607609+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-01T16:20:47.248202+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=41e9f39b-e908-4cee-a430-0d7f44a17590 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:20:47.891459+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=9f244daf-7a3e-405e-b445-2fadd8b2735b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:13.187594+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=455ccd5e-e389-49be-b892-e5e222c9864f fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:13.805998+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=112a5f08-632e-463d-b8e8-ed6de13b3596 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:57.528020+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=d956df30-8352-4a54-80e6-2aa1fc96276b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:58.138751+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=96b2bf0d-df05-4d7e-9018-0b09e1dfa748 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https

不确定Heroku的情况,但对于AppEngine来说,将端口更改为8080是否有效

例如:

const server = app.listen(8080, () => {
  const host = server.address().address;
  const port = server.address().port;

  console.log(`Example app listening at http://${host}:${port}`);
});

From

不确定Heroku的情况,但对于App Engine,将端口更改为8080是否有效

例如:

const server = app.listen(8080, () => {
  const host = server.address().address;
  const port = server.address().port;

  console.log(`Example app listening at http://${host}:${port}`);
});