2017-08-20 88 views
1

我尝试一些实践上谷歌云平台App Engine的具体。应用引擎部署的NodeJS错误

同样,我创建了一个简单的nodejs应用程序,它只在响应中发送Hello Wold消息。

但我无法访问端点并提示以下错误: enter image description here

下面

是我的文件:

aap.yaml

runtime: nodejs 
env: flex 

index.js

'use strict'; 

const http = require('http'); 
const port = 443; 

const requestHandler = (request, response) => { 
    console.log(request.url); 
    response.end('Hello Node.js Server!'); 
} 


const server = http.createServer(requestHandler); 
server.listen(port, (err) => { 
    if (err) { 
    return console.log('something bad happened', err) 
    } 
    console.log(`server is listening on ${port}`) 
}); 

的package.json

{ 
    "name": "test-pro-for-gcm", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "start": "node index.js", 
    "deploy": "gcloud app deploy", 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "", 
    "license": "ISC" 
} 

更新1 在GCP日志,16:31:59.000 server is listening on 443

+0

嘿,自从周六以来,我一直有同样的错误。将在这里观看线索,希望我们得到一个反馈。 –

+0

我从我自己创建了这个应用程序,并且出现错误。现在我正在部署hello-world演示应用程序,并按预期工作。您可以从这里下载演示https://codeload.github.com/GoogleCloudPlatform/nodejs-docs-samples/zip/master – dearvivekkumar

回答

0

将接收HTTP请求的端口是8080。

使用PORT environment variable在你的代码使其与App Engine环境兼容:const port = process.env.PORT || 443;

相关问题