Skip to content

unable to send commands to sentinel #1947

@mkl262

Description

@mkl262

Hi,

Im using ioredis to connect to a sentinel server, and Im able to run all redis commands successfully. But when I try to run commands on sentinel, I get an error (see below). I also ran wireshark on my computer while running the code, and I saw that the sentinel command is sent to the redis master ip. Is there something wrong that I did?

code:

const Redis = require('ioredis');

const redis = new Redis({
  sentinels: [{ host: 'localhost', port: 26379 }],
  name: 'myMaster', // The name of your master (as configured in Sentinel)
});

redis.on('connect', () => {
  console.log('Connected to Redis Sentinel');
});

// Get master address and print it
redis.sentinel('masters', (err, masters) => {
  if (err) {
    console.error('Error getting masters:', err);
  } else {
    console.log('Masters:', masters);
  }
});

error:

Connected to Redis Sentinel
Error getting masters: ReplyError: ERR unknown command 'sentinel', with args beginning with: 'masters' 
    at parseError (/Users/michael/Documents/Widebridge/synch-common/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/Users/michael/Documents/Widebridge/synch-common/node_modules/redis-parser/lib/parser.js:302:14) {
  command: { name: 'sentinel', args: [ 'masters' ] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions