Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR unknown command SELECT, with args beginning with: 2 #1991

Closed
alpha-r2net opened this issue Feb 17, 2022 · 2 comments
Closed

ERR unknown command SELECT, with args beginning with: 2 #1991

alpha-r2net opened this issue Feb 17, 2022 · 2 comments
Labels

Comments

@alpha-r2net
Copy link

try to connect to cluster to default database number 2 the on connect get error unknown command SELECT

import { createCluster } from 'redis';
(async () => {
    const REDIS_USERNAME = 'username';
    const REDIS_PASSWORD = 'password';
    const cluster = createCluster({
        rootNodes: [
            {
                url: `redis://<ip>:<port>`,
            },
            {
                url: `redis://<ip>:<port>`,
            },
            {
                url: `redis://<ip>:<port>`,
            }
        ],
        defaults: {
            username: REDIS_USERNAME,
            password: REDIS_PASSWORD,
            database: 2
        }

    });
    cluster.on('error', (err) => console.log('Redis Cluster Error', err));
    console.log('before connection');
    await cluster.connect();
    console.log('connected to cluster...');
    const value = await cluster.get('key');
    console.log(value);
    await cluster.disconnect();
})();

Environment:

  • Node.js Version: 16.14.0
  • Redis Server Version: 5.0.7
  • Node Redis Version: 4.0.3
  • Platform: Windows 10
@leibale
Copy link
Collaborator

leibale commented Feb 18, 2022

https://redis.io/topics/cluster-spec#implemented-subset
"Redis Cluster does not support multiple databases like the standalone version of Redis. There is just database 0 and the SELECT command is not allowed."

@leibale leibale closed this as completed Feb 18, 2022
@alpha-r2net
Copy link
Author

@leibale ,
I do not understand you, really ?
how you see, that I am talking about multi databases?
if you not understand the question please ask.

I'm using today with "ioredis" library
in ioredis my configuration connection is

{
        sentinels: [{ host: '<ip>', port: <port>},
            { host: '<ip>', port: <port> },
            { host: '<ip>', port: <port> }],
        name: '<name>',
        password: '<password>',
        sentinelRetryStrategy: function (times) {
            return Math.min(times * 10, 1000)
        },
        db: 2
    }

and this is working for me.
but the library make me support new command in code.
they not support it naturally when I just connect to redis.
such as set (members) some of the commads need to sign for them.
make it so harder then to use redis library

now I want to use redis and this configuration is from yours doc

{
        rootNodes: [
            {
                url: `redis://<ip>:<port>`,
            },
            {
                url: `redis://<ip>:<port>`,
            },
            {
                url: `redis://<ip>:<port>`,
            }
        ],
        defaults: {
            username: REDIS_USERNAME,
            password: REDIS_PASSWORD,
            database: 2
        }

    }

and it not working for me.
the error is throw that the bug error title
only database is do, is connecting to database 2 and not for default is 0

now I hope is more clearly
and hope get answer,
and if you do not want to help bring another one to answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants