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

233
Vistas
How to terminate persistent connection in axios?

I'm working on the project which needs to establish a persistent connection with web-server. I'm planning to use axios like this.

const axiosInstance = axios.create({
  baseURL: 'https://httpbin.org/headers',
  headers: { 'X-Custom-Header': 'foobar' },
  httpsAgent: new https.Agent({
    keepAlive: true,
  }),
});

axiosInstance
  .get()
  .then((response) => console.log(response.headers))
  .catch((err) => console.log(err.message));

With the get call , the connection is established , but after some calculation or processing I need to break this persistent connection (on-demand basis), is there a way to do this in axios?

Also if this instance of axios axiosInstance gets deleted (the reference of this object goes out of scope and the GC reclaims the memory consumed by it) , will the keep-alive or persistent connection automatically ends with server?

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