Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!