admin管理员组文章数量:1420145
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)
本文标签: javascriptConnectredis store don39t work with socketioStack Overflow
版权声明:本文标题:javascript - Connect-redis store don't work with socket.io - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745325423a2653569.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论