I am trying to deploy a simple application to Heroku which makes use of the modules 'socket.io' and 'connect'. When I deploy the application I get a Permission Denied error and the application crashes. I am getting the port number from the environment property 'PORT'. I am configuring socket.io to use long polling rather than WebSockets (as I know they are not supported).
Can someone tell me what I'm doing wrong?
var io = require('socket.io'),
connect = require('connect');
var port = process.env.PORT || 5000;
var app = connect().use(connect.static('public')).listen(port);
var chat_room = io.listen(app);
chat_room.configure(function () {
chat_room.set("transports", ["xhr-polling"]);
chat_room.set("polling duration", 10);
});
chat_room.sockets.on('connection', function(socket){
socket.emit('entrance', {message:'Welcome to the chat room.'});
socket.on('disconnect', function(){
chat_room.sockets.emit('exit', {message:'A chatter has disconnected.'});
});
socket.on('chat', function(data){
chat_room.sockets.emit('chat',{message: '# ' + data.message});
});
chat_room.sockets.emit('entrance', {message: 'A new chatter is online.'});
});
Here is the error from the log:
2013-02-01T04:24:04+00:00 app[web.1]: Error: EACCES, Permission denied
2013-02-01T04:24:04+00:00 app[web.1]: at Server.listen (net.js:1063:20)
2013-02-01T04:24:04+00:00 app[web.1]: node.js:134
2013-02-01T04:24:04+00:00 app[web.1]: at Server._doListen (net.js:1098:5)
2013-02-01T04:24:04+00:00 app[web.1]: at net.js:1069:14
2013-02-01T04:24:04+00:00 app[web.1]: at Object.lookup (dns.js:153:45)
2013-02-01T04:24:04+00:00 app[web.1]: at Object.listen (/app/node_modules/socket.io/lib/socket.io.js:67:12)
2013-02-01T04:24:04+00:00 app[web.1]: at Object.<anonymous> (/app/main.js:8:20)
2013-02-01T04:24:04+00:00 app[web.1]: at Module.load (module.js:336:31)
2013-02-01T04:24:04+00:00 app[web.1]: at Module._compile (module.js:404:26)
2013-02-01T04:24:04+00:00 app[web.1]: at Function._load (module.js:297:12)
2013-02-01T04:24:04+00:00 app[web.1]: at Object..js (module.js:410:10)
2013-02-01T04:24:06+00:00 heroku[web.1]: Process exited with status 1
2013-02-01T04:24:06+00:00 heroku[web.1]: State changed from starting to crashed
Thanks!