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.0.9
- Environment type: Load balancing, autoscaling
and have set Proxy Server to none.
I've successfully compressed & uploaded via the console my code:
package.json
{
"name": "cool",
"version": "0.0.0",
"dependencies": {
"ws": "0.4.x"
}
}
server.js
var wss = new (require('ws')).Server({port: (process.env.PORT || 3000)})
wss.on('connection', function(ws) {
console.log('connected')
ws.on('message', function(message) {
console.log(message)
ws.send(message)
});
ws.on('close', function() {
console.log('disconnected')
})
})
I also tried including the node_modules
directory.
After running:
wscat -c ws://default-environment-xxxxxxxxxx.elasticbeatalk.com/
I got back:
Error: unexpected server response (200)
How can I find out more about that error?
Amazon sets the PORT environment variable to 8080. So, I also tried:
wscat -c ws://default-environment-xxxxxxxxxx.elasticbeatalk.com:8080/
But, that just hung and then returned:
Error: connect ETIMEDOUT
Also, when I do establish a WebSocket connection, I want the server to allow it to stay open indefinitely, unlike Heroku's WebSocket implementation, which times out after 60 seconds.
Is there a detailed tutorial on how to do this?