1

我正在尝试将一个简单的应用程序部署到 Heroku,它使用模块“socket.io”和“连接”。当我部署应用程序时,我收到 Permission Denied 错误并且应用程序崩溃。我从环境属性“PORT”获取端口号。我正在将 socket.io 配置为使用长轮询而不是 WebSockets(因为我知道它们不受支持)。

有人可以告诉我我做错了什么吗?

     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.'});
 });

这是日志中的错误:

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

谢谢!

4

0 回答 0