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

couldn't get slot allocation #46

Open
everlose opened this issue Jan 5, 2021 · 3 comments
Open

couldn't get slot allocation #46

everlose opened this issue Jan 5, 2021 · 3 comments

Comments

@everlose
Copy link

everlose commented Jan 5, 2021

Help me:

const client = new RedisClustr({
    servers: [
      {
        host: '127.0.0.1',
        port: 6379
      }
    ]
})
client.get(key, function (err, data) { console.log(err.message) }) // 'couldn't get slot allocation'

I know my local redis didn't support cluster mode. Is there a way to connect normal local redis?

@jtara1
Copy link

jtara1 commented Sep 16, 2021

using redis-6.2.5

I'm having this problem too. I setup my redis cluster with the script from the redis lib, utils/create-cluster/create-cluster. I added retry logic using async-retry with

const response = await retry(() => util.promisify(redis.set).bind(redis)(key, val));

and I added some debug logs to redis-clustr lib itself so I can see the problem appears to be that none of the connections have ready equal to true.

  redis-clustr tryClient() +30s
  redis-clustr getRandomConnection(): connections 6 +1ms
  redis-clustr getRandomConnection(): connections ready = 0 +0ms
  redis-clustr tryClient(): error - couldn't get slot allocation +0ms

The weird thing is is that I can connect to one of my redis clients of this cluster with redis-cli -c -p 30001 and run commands like cluster slots, keys *, set a 1, or get a just fine. I can run another local script using this redis-clustr lib locally calling get or set redis commands while my main app is retrying and failing to get a ready connection.

@jtara1
Copy link

jtara1 commented Sep 16, 2021

try using the minimal config from their example like:

const RedisClustr = require('redis-clustr');
const Redis = require('redis');

(async () => {
  try {
    const servers = [
      {
        "host": "127.0.0.1",
        "port": 30001
      },
      {
        "host": "127.0.0.1",
        "port": 30002
      },
      {
        "host": "127.0.0.1",
        "port": 30003
      },
      {
        "host": "127.0.0.1",
        "port": 30004
      },
      {
        "host": "127.0.0.1",
        "port": 30005
      },
      {
        "host": "127.0.0.1",
        "port": 30006
      }
    ];

    const redis = new RedisClustr({
      servers,
      createClient: function(port, host) {
        // this is the default behaviour
        return Redis.createClient(port, host);
      }
    });

    redis.on('error', console.error);

    redis.set('a', 3, Redis.print);
    redis.get('a', Redis.print);

    console.log('done');
  } catch (error) {
    console.error(error);
  }
})();

edit: this still wasn't enough for me

@menocomp
Copy link

@everlose I have the same issue/limitation.
I believe with this library we have to have a redis-cluster not just a normal redis instance.
It would be good though to support backward-compatibility.

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

No branches or pull requests

3 participants