Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
Can't kill Redis connection from Node JS using ioredis

I'm using ioredis package and want to kill connections with idle time > 30 seconds. I use this code:

 const clientList = await redisClient.client('list');

  if (typeof clientList === 'string') {
    await Promise.all(
      clientList
        .split('\n')
        .filter(item => item !== '')
        .filter(
          item => parseInt(item.match(/.*?idle=(.*)? flags=/)[1], 10) > 30
        ) // idle > 30 seconds
        .map(async item => {
          const id = item.match(/.*?id=(.*)? addr=/)[1];
          const res = await redisClient.client('kill', 'id', id);
          console.log('res', res);
        })
    );
  }

And I get this in console:

res 1
res 1
res 1
...
res 1
res 1

But the connections are not killed.

I've tried to debug it, but everything seems to be ok, except it's just doesn't work as expected.

Also I've tried to manage it via Redis config in redis-cli:

CONFIG SET TIMEOUT 30

This way I see that the number of connections stay the same, but their idle values are resetting (like they reconnect just after server kill them).

Help with it please. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda