2013-04-30 74 views
1

我似乎无法让socket.io RedisStore在heroku上工作。我能够连接到RedisToGo,但是当我打电话new RedisStore()如果我没有提供密码给RedisToGo连接如我得到的错误,我希望得到:Error: Ready check failed: ERR operation not permittedsocket.io RedisStore在heroku上工作吗?

我的配置:

var http = require('http') 
    , sio = require('socket.io') 
    , _ = require('lodash') 
    , port = process.env.PORT || 8000 
    , httpServer = http.createServer().listen(port) 
    , io = sio.listen(httpServer) 
    , RedisStore = sio.RedisStore 
    , organization = require('./controllers/organization') 
    , chat = require('./controllers/chat') 
    , group = require('./controllers/group') 
    , util = require('util'); 

var DEV = false; 

if (DEV) { 
    var pub = require('redis').createClient() 
    , sub = require('redis').createClient() 
    , client = require('redis').createClient(); 
} 
else { 
    var rtg = require("url").parse(process.env.REDISTOGO_URL); 
    var pub = require("redis").createClient(rtg.port, rtg.hostname); 
    pub.auth(rtg.auth.split(":")[1], function(err) { console.log('pub ERR: ' + util.inspect(err)); }); 


    var sub = require("redis").createClient(rtg.port, rtg.hostname); 
    sub.auth(rtg.auth.split(":")[1], function(err) { console.log('sub ERR: ' + util.inspect(err)); }); 

    var client = require("redis").createClient(rtg.port, rtg.hostname); 
    client.auth(rtg.auth.split(":")[1], function(err) { console.log('client ERR: ' + util.inspect(err)); }); 

} 


io.configure(function() { 
    //create redis connection, set options 

    var opts = {host: '127.0.0.1', port: '6379'} 
    /******* PROBLEM HERE ******/ 
    , redisStore = new RedisStore({redisPub: pub, 
            redisSub: sub, 
            redisClient: client}); 


    //io.set('store', redisStore); 
    io.set('transports', ['xhr-polling']); 
    //io.set('close timeout', 30); 
    //io.set('hearbeat timeout', 28); 
    //io.set('hearbeat interval', 15); 
    io.set("polling duration", 10); 
    //io.set('log level', 0); 


    if (DEV) { 
    require('./lib/dev_static').static(io); 
    } 
    else { 
    require('./lib/prod_static').static(io); 
    } 

}); 

io.sockets.on('connection', function(socket) { 
    etc ... 

}); 

错误日志从Heroku的:

2013-04-30T19:38:30.070457+00:00 heroku[web.1]: Starting process with command 'node app.js' 2013-04-30T19:38:30.917568+00:00 app[web.1]: info: socket.io started 2013-04-30T19:38:31.002714+00:00 app[web.1]: client ERR: null 2013-04-30T19:38:31.009598+00:00 app[web.1]: 2013-04-30T19:38:31.010050+00:00 app[web.1]: /app/node_modules/socket.io/node_modules/redis/index.js:506 2013-04-30T19:38:31.003255+00:00 app[web.1]: pub ERR: null 2013-04-30T19:38:31.001801+00:00 app[web.1]: sub ERR: null 2013-04-30T19:38:31.010729+00:00 app[web.1]: throw callback_err; 2013-04-30T19:38:31.011043+00:00 app[web.1]: ^ 2013-04-30T19:38:31.015164+00:00 app[web.1]: at Command.callback (/app/node_modules/socket.io/node_modules/redis/index.js:367:14) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisClient.return_error (/app/node_modules/socket.io/node_modules/redis/index.js:502:25) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisClient.on_info_cmd (/app/node_modules/socket.io/node_modules/redis/index.js:319:35) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.send_error (/app/node_modules/socket.io/node_modules/redis/lib/parser/javascript.js:266:14) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/socket.io/node_modules/redis/index.js:79:14) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisClient.on_data (/app/node_modules/socket.io/node_modules/redis/index.js:478:27) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.execute (/app/node_modules/socket.io/node_modules/redis/lib/parser/javascript.js:125:22) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.<anonymous> (/app/node_modules/socket.io/node_modules/redis/index.js:262:14) 2013-04-30T19:38:31.015164+00:00 app[web.1]: Error: Ready check failed: ERR operation not permitted 2013-04-30T19:38:31.015476+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17) 2013-04-30T19:38:31.015164+00:00 app[web.1]: at RedisReplyParser.EventEmitter.emit (events.js:95:17) 2013-04-30T19:38:32.242663+00:00 heroku[web.1]: Process exited with status 8 2013-04-30T19:38:32.257231+00:00 heroku[web.1]: State changed from starting to crashed

回答