2017-08-20 90 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;

相關問題