I know that Heroku automatically assigns a port number to your instance and doesn't work when you define a specific one like '3000'. But when I try to change my port number to make use of environment variables (like suggested in Heroku's documents and a few stack overflow answers), I always get
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
The app works perfectlt locally and I was wondering how best to change my code to ensure that it works on Heroku:
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
port = 3000,
// hash object to save clients data,
// { socketid: { clientid, nickname }, socketid: { ... } }
chatClients = new Object();
server.listen(port);
Here are some of the links to things I've tried, etc:
https://devcenter.heroku.com/articles/preparing-a-codebase-for-heroku-deployment (point number 4)
Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
https://help.heroku.com/P1AVPANS/why-is-my-node-js-app-crashing-with-an-r10-error