Reputation: 57
Lately I've been using Node.js to create a chat application and as I went to host it on heroku, it keeps popping up with this error. My code can be found here. I believe it is something to do with the port not being dynamically allocated but how exactly would I do this in this setup?
2015-07-12T11:00:35.931639+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-spire-4645.herokuapp.com request_id=1d5bbae1-6fcc-42cf-b987-d17b45a3ef96 fwd="101.184.151.145" dyno= connect= service= status=503 bytes=
Upvotes: 0
Views: 1258
Reputation: 2253
You need to bind the port to the PORT environment variable (this lets the port be set by Heroku).
As you are setting the port in your config file, you could use something like this:
var config = JSON.parse(fs.readFileSync('./config.json'))
var port = process.env.PORT || config.port;
var server = new ws.Server({host: config.host, port: port})
Upvotes: 1