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

380
Visualizações
ioredis - handle connection retry and ECONNRESET

I'm trying to handle redis retry connection if there's any network issue. It looks like it's working but I'm not sure because sometimes I get ECONNRESET.

redisOptions: {
        sentinels: [
            { host: process.env.redis_server_1, port: process.env.redis_port_1 },
            { host: process.env.redis_server_2, port: process.env.redis_port_2 },
            { host: process.env.redis_server_3, port: process.env.redis_port_3 },
        ],
        name: 'mymaster'
    },

redisOptions object is defined in configuration file.

    function updateConfigurations(){
       console.log(configuration.redisOptions);
       configuration.redisOptions.sentinelRetryStrategy = (times) => {
        console.log('Trying to connect to Redis ', times);
        return Math.min(times * 100, 10000);
       }
   //  configuration.redisOptions.retryStrategy = (times) => Math.min(times * 50, 2000);
   }
    

I'm testing this by disconnecting from VPN. The moment I disconnected from VPN, below error message is getting printed on console.

[ioredis] Unhandled error event: Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)

And then below logging for retry connecting

[ioredis] Unhandled error event: Error: All sentinels are unreachable. Retrying from scratch after 400ms. Last error: Connection is closed.

Is this a correct way to handle retry connecting? How should I handle ECONNRESET?

over 4 years ago · Santiago Trujillo
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