0

I'm using connect-redis - https://github.com/visionmedia/connect-redis in my project.

Is there any on error event? Something, where I can put callback to tell me, that (for example) my app can't connect to redis server?

I tried to search but I have found nothing useful.

Part of my config code:

app.use(express.methodOverride());      
app.use(expressLayouts);
app.use(express.json());
// app.use(express.logger('dev'));

app.use(express.cookieParser());
app.use(express.session({
    secret: 'have a fun',
    maxAge: new Date(Date.now() + 3600000),
    store: new RedisStore( config[app.get('env')].redis ),
    // store: new FileStore({path:'./data/sessions', useAsync:true})
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());

app.use(app.router);

Every useful tip is welcome...

Jan Jůna
  • 4,965
  • 3
  • 21
  • 27

1 Answers1

0

The library you are using is backed by awesome node-redis hence it should have events attached to it like error event.

So, considering following is the code you are using to create an object -

var session = require('express-session'),
    RedisStore = require('connect-redis')(session);
RedisStore.on('error', function(err){ 
  console.log("Connection error.");
})

Above code is not tested, but it should work.

Just take Redis server down and then start node server, it should print the log. If this works, then go here and you will find more 5 events and some more stuff.

Pranav
  • 2,054
  • 4
  • 27
  • 34