I the simplest nodejs application that uses Redis to store sessions. I have downloaded and started reds-server on windows, but it bringsup the following error message
ReplyError: ERR wrong number of arguments for 'set' command
at parseError (D:\Org\Projects\Up\Image metadata\Lab\Login with store\node_modules\redis-parser\lib\parser.js:179:12)
at parseType (D:\Org\Projects\Up\Image metadata\Lab\Login with store\node_modules\redis-parser\lib\parser.js:302:14)
My simple node.js express app is the following
const express = require("express");
const session = require("express-session");
const redis = require("redis");
const connectRedis = require("connect-redis");
const bodyParser = require("body-parser");
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
const RedisStore = connectRedis(session);
const redisClient = redis.createClient({
host:"localhost",
port:6379
})
app.use(session({
store: new RedisStore({client: redisClient}),
secret:"shhhhh4",
resave: false,
saveUninitialized: false,
cookie:{
secure: false,
httpOnly: false,
maxAge: 5 * 30 * (24 * (1000 * 60 * 60))
}
}));
app.get("/", (req,res)=>{
const sess = req.session;
if (sess.username && sess.password) {
if (sess.username) {
res.write(`<h1>Welcome ${sess.username} </h1><br>`)
res.write(
`<h3>This is the Home page</h3>`
);
res.end('<a href=' + '/logout' + '>Click here to log out</a >')
}
} else {
res.sendFile(__dirname + "/login.html")
}
});
app.post("/login", (req, res) => {
const sess = req.session;
const { username, password } = req.body
sess.username = username
sess.password = password
console.log(req.body);
// add username and password validation logic here if you want.If user is authenticated send the response as success
res.end("success")
});
what is the problem? I have installed the latest of those imported modules, but still get the error
I am using Redis server version 2.4.5
and redis and redis-connect 6.14.6
Redis server version 2.4.5and redis and redis-connect6.14.6