axios / axios

Promise based HTTP client for the browser and node.js
https://axios-http.com
MIT License
105.8k stars 10.98k forks source link

connect ETIMEDOUT #6202

Open deepak-agendaboa opened 9 months ago

deepak-agendaboa commented 9 months ago

Describe the bug

I'm using Axios package for the http requests from my Firebase cloud function. I have a cloud function which index the data in AWS openSearch. It uses the PUT request. This cloud function has timeout of 2 mins.

Sometimes http requests are failed with error connect ETIMEDOUT <ip>

Earlier I was thinking that the error is from the openSearch side. So I contacted AWS support. They identified that these requests are not reaching the openSearch endpoint. The timeout error is from the client side itself.

I'm not sure why the request is not able to connect with openSearch endpoint and ends with timeout error. What is the reason and how it can be fixed?

To Reproduce

No response

Code snippet

This is how I use the Axios instance.

const axios = require('axios').default;
const instance = axios.create({
   baseURL: HOST,
   auth: AUTH,
});

instance.put()
.then((response) => {

}).catch((error) => {

});

Expected behavior

No response

Axios Version

1.2.2

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

Node 16

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

deepak-agendaboa commented 9 months ago

Can anyone help?

HKMANOJ commented 9 months ago

can i work on this?

deepak-agendaboa commented 9 months ago

It seems that my problem is related to this https://stackoverflow.com/questions/63064393/getting-axios-error-connect-etimedout-when-making-high-volume-of-calls

HKMANOJ commented 9 months ago

const axios = require('axios').default; const http = require('http'); const https = require('https');

const instance = axios.create({ baseURL: HOST, auth: AUTH, httpAgent: new http.Agent({ keepAlive: true }), httpsAgent: new https.Agent({ keepAlive: true }), });

instance.put() .then((response) => { console.log(response.data); }) .catch((error) => { console.error(error); }); check out this code

deepak-agendaboa commented 9 months ago

By adding the keepAlive: true and timeout: 120000 has reduced the errors but still the issue exists.

Not sure how to resolve it completely. It's weird that there is no response on this from the Axios team yet.

HiptJo commented 9 months ago

+1

jwd-dev commented 5 months ago

+1

StreetStrider commented 4 months ago

6106; #6008

shared symptoms