socket.io RedisStore を heroku で動作させることができないようです。RedisToGo に接続できnew RedisStore()
ますが、呼び出すと、次のような RedisToGo 接続にパスワードを提供していなかった場合に発生すると予想されるエラーが発生します。Error: Ready check failed: ERR operation not permitted
私の構成:
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