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

240
Visualizações
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 à 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