session.socket.io抛出:“错误:无法按键查找会话:jsessionid”

时间:2014-09-20 13:24:06

标签: node.js http session express socket.io

我有两台服务器:

  1. 网络服务器:127.0.0.1:3000
  2. socket.io server:127.0.0.1:4000
  3. 我正在尝试使用socket.io服务器中的“session.socket.io”模块读取会话。 但我明白了:

      

    “错误:无法按键查找会话:jsessionid”

    网络服务器代码:

    // Session
    var session = require('express-session');
    var RedisStore = require('connect-redis')(session);
    app.use(session({store: new RedisStore(), key:'jsessionid', secret:credentials.cookieSecret}));
    app.use(require('cookie-parser')(credentials.cookieSecret));
    

    socket.io服务器:

    // Cookie
    var cookieParser = require('cookie-parser');
    app.use(cookieParser(credentials.cookieSecret));
    
    // Session
    var session = require('express-session');
    var RedisStore = require('connect-redis')(session)
        , redisStore = new RedisStore();
    app.use(session({store: redisStore , key:'jsessionid', secret:credentials.cookieSecret}));
    
    var SessionSockets = require('session.socket.io')
      , sessionSockets = new SessionSockets(io, redisStore , cookieParser(), 'jsessionid'); 
    
    sessionSockets.on('connection', function(err, socket, session) {
    
        console.log('connection event occured');
        console.log("session is: " + session);
        console.log("error is: " + err);
    });
    

    为什么会这样?

0 个答案:

没有答案