0
votes

I have tried to build an Express 4 Web App using Azure. I found on several articles that I can store the sessions in Azure Redis Cache. However, how should I connect my web app to the redis cache?

var session = require('express-session');
var redis = require('redis');
var RedisStore = require('connect-redis')(session); 
var client = redis.createClient(6380, 'MyHost', { auth_pass: 'MyPass', tls: { servername: 'MyHostName' } });

app.use(session({
    secret: 'keyboard cat',
    key: 'sid',
    resave: false,
    saveUninitialized: false,
    store: new RedisStore(client);
}));

But then it returns an error when I run the app. Saying TypeError: this.client.unref is not a function

How can I solve this? Thanks!

1

1 Answers

0
votes

You might make a mistake in RedisStore constructor.

Change the following line of code store: new RedisStore(client); as below:

store: new RedisStore({client: client});