Tôi có một câu hỏi dễ dàng cho người dùng kết nối lại.Cửa hàng Connect-redis không hoạt động với socket.io
Tôi muốn sử dụng nó với socket.io với chức năng io.set('store', something)
. Tôi không biết tại sao, khi tôi làm
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);
Nó nói Object #<RedisStore> has no method 'subscribe'
Cảm ơn bạn! Tôi sợ vì tôi nghĩ rằng tôi sẽ phải tạo ra bộ thứ hai của pub/sub/client, một cho socket.io và một cho express. Bây giờ tôi thấy rằng 'new RedisSessionStore' chấp nhận một redis client như một tùy chọn. – Jakub
Điều này có nghĩa rằng dòng này ở trên var RedisSessionStore = require ('connect-redis') (express); nên được loại bỏ khỏi tệp app.js hoặc chỉ cần đổi tên biến để tạo phần io.set? và nếu var bị xóa, bạn lưu trữ phiên thể hiện ở trên là gì? – Lion789