我有一个奇怪的问题,我没有任何线索发生了什么。当我开始socket.io
时会以某种方式将会话保存到redis中,但当我评论socket.io
时,它们会正常工作。代码可以找到here:没什么不寻常的。数据库崩溃后,此代码停止工作。当我再次尝试运行该应用时,它说redis connection is already in use
。我找到并杀死了使用此连接的节点进程,我可以再次启动我的应用程序,但现在会出现会话问题。
var config = require('./config')
, express = require('express')
, routes = require('./routes')
, RedisStore = require('connect-redis')(express)
, sessionStore = new RedisStore(config.redis)
, app = express.createServer();
app.configure(function () {
app.use(express.static(__dirname + '/public'));
app.use(express.cookieParser('keyboard cat'));
app.use(express.session({
secret: config.sessionSecret,
key: 'express.sid',
store: sessionStore
}));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
})
app.configure('development', function () {
app.use(express.errorHandler());
});
app.enable('jsonp callback');
routes.init(app);
app.listen(config.port);
console.log("listening on port " + config.port);
// socket.io
var io = require('socket.io').listen(app);
io.configure(function() {
io.set("polling duration", 10);
io.enable('browser client minification');
io.enable('browser client etag');
io.enable('browser client gzip');
io.set('log level', 3);
io.set('transports', ['xhr-polling']);
}
);