I have an easy question for someone who use connect-redis.
I want to use it with socket.io with the function io.set('store', something)
.
I don't know why, when I do
var RedisSessionStore = require('connect-redis')(express);
var sessionStore = new RedisSessionStore();
app.use(express.session({
secret: 'some totally secret key',
cookie: {
maxAge: 1000 * 60 * 60
},
store: sessionStore
}));
//and then I wan't to use the session store for socket.io
io.set('store', sessionStore);
It says Object #<RedisStore> has no method 'subscribe'
I have an easy question for someone who use connect-redis.
I want to use it with socket.io with the function io.set('store', something)
.
I don't know why, when I do
var RedisSessionStore = require('connect-redis')(express);
var sessionStore = new RedisSessionStore();
app.use(express.session({
secret: 'some totally secret key',
cookie: {
maxAge: 1000 * 60 * 60
},
store: sessionStore
}));
//and then I wan't to use the session store for socket.io
io.set('store', sessionStore);
It says Object #<RedisStore> has no method 'subscribe'
1 Answer
Reset to default 9connect-redis
is a Redis-backed session store for Connect/Express, but it's inpatible with the 'store protocol' that socket.io
uses.
Instead, you need to use the Redis store implementation shipped with socket.io
:
var SocketIoRedisStore = require('socket.io/lib/stores/redis'),
redis = require('socket.io/node_modules/redis');
...
io.set('store', new SocketIoRedisStore({
redisPub : redis.createClient(),
redisSub : redis.createClient(),
redisClient : redis.createClient()
}));
(docs)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745325424a4622634.html
评论列表(0条)