Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

352
Visualizações
socket.io-redis keeps throwing NOAUTH error

I am trying to connect to my redis server that password protected but for some reason I keep getting the error:

events.js:141 throw er; // Unhandled 'error' event ^ ReplyError: Ready check failed: NOAUTH Authentication required. at parseError (/home/ubuntu/TekIT/ITapp/node_modules/redis-parser/lib/parser.js:193:12) at parseType (/home/ubuntu/TekIT/ITapp/node_modules/redis-parser/lib/parser.js:303:14)

I know the password is correct because i tried it in the redis-cli and it works fine. Here is the code below:

var redis = require('redis');

var client = redis.createClient(redisPort, redisHostname, { auth_pass: 'password1' });


var redisSubscriber = redis.createClient(redisPort, redisHostname, { auth_pass: 'password1' });




// Create and use a Socket.IO Redis store
var RedisStore = require('socket.io-redis');
io.set('store', new RedisStore({
    redisPub: client,
    redisSub: redisSubscriber,
    redisClient: client
}));

Does anyone know why I am getting this error?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You should initialize socket.io-redis after ready event.

Also you should call to client.auth('password1', ()=>{}) function.

Check this part of documentation:

When connecting to a Redis server that requires authentication, the AUTH command must be sent as the first command after connecting. This can be tricky to coordinate with reconnections, the ready check, etc. To make this easier, client.auth() stashes password and will send it after each connection, including reconnections. callback is invoked only once, after the response to the very first AUTH command sent. NOTE: Your call to client.auth() should not be inside the ready handler. If you are doing this wrong, client will emit an error that looks something like this Error: Ready check failed: ERR operation not permitted.

Try this code:

var redis = require('redis');
const redisPort = 6379
const redisHostname = 'localhost'
const password = 'password1'

var p1 = new Promise((resolve, reject)=>{
    var client = redis.createClient(redisPort, redisHostname, { auth_pass: 'password1' });
    client.auth(password)
    client.on('ready', ()=>{
        resolve(client)
    })
})

var p2 = new Promise((resolve, reject)=>{
    var redisSubscriber = redis.createClient(redisPort, redisHostname, { auth_pass: 'password1' });
    redisSubscriber.auth(password)
    redisSubscriber.on('ready', ()=>{
        resolve(redisSubscriber)
    })
})

Promise.all([p1,p2]).then(([client, redisSubscriber])=>{
    console.log('done', client)
    client.ping((err, data)=>{
        console.log('err, data', err, data)
    })

    // Create and use a Socket.IO Redis store
    var RedisStore = require('socket.io-redis');
    io.set('store', new RedisStore({
        redisPub: client,
        redisSub: redisSubscriber,
        redisClient: client
    }));
})
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda