1

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

2
  • What version of redis are you running? Commented Feb 23, 2021 at 16:08
  • @eol I am using Redis server version 2.4.5 and redis and redis-connect 6.14.6 Commented Feb 23, 2021 at 17:05

1 Answer 1

1

You need to update to a newer version of redis as your version is rather outdated and does not support the given options of the set command, see this github issue for further details.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I updated, and npm connect-redis --version and npm redis --version now give me 6.14.6 But the problem still persists. I get the same error
It worked when I updated the server application itself to 3.0.5
Yes, that's what I meant - glad, you got it working :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.