How to deploy a Node.js WebSocket server to Amazon Elastic Beanstalk?

后端 未结 2 1448
花落未央
花落未央 2021-01-16 12:24

Using the Elastic Beanstalk web console, I\'ve launched a new Web Server 1.0 environment with:

  • Predefined configuration: Node.js, 64bit Amazon Linux 2014.09 v1
2条回答
  •  迷失自我
    2021-01-16 13:04

    If you have set up your package.json file correctly (primarily by using --save when npm installing) then you should not have to include the node_modules directory.

    Check that the process.env.PORT setting is not changing the listened port - AWS EB usually sets the port to 8081.

    To find the port being reported, you can add console.log(process.env.PORT) in your code, then connect via ssh to the server and run tail -f var/log/nodejs/nodejs.log (this monitors the log output of node.js). Then hit your server again and see what port shows up in the log output on your ssh connection.

    To investigate the error you are getting, add a ws.on('error',...) function and log what you want.

提交回复
热议问题