I am trying to do http call using axios in node azure function app and **sometimes** I get ETIMEDOUT error. The timeout duration is less than what's set.
Error: connect ETIMEDOUT 'ip address of endpoint':443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:129:14)
const axios = require('axios');
const axoisInstance = axios.create({baseURL: myurl});
axoisInstance.defaults.headers.get['Content-Type'] = 'application/json';
axoisInstance.defaults.timeout = 120000;
module.exports = async function (context, req) {
axoisInstance.defaults.headers.common = {'Authorization': 'Bearer ' + token}
let response = await axoisInstance.get(getURL);
}
Asked
Active
Viewed 1,287 times
1

Vivek Ranjan
- 1,432
- 2
- 15
- 37
1 Answers
1
I test with same code with yours, it works fine in my side. The line of code axoisInstance.defaults.timeout = 120000;
is valid. So it is most likely a server side timeout which is set less than 2min.
If the error was caused by client timeout which you set in the code axoisInstance.defaults.timeout = 120000;
, it will show error like Exception: Error: timeout of 120000ms exceeded
(I test with set 60000 timeout and provide the screenshot below). But your error message is Error: connect ETIMEDOUT 'ip address of endpoint':443
.

Hury Shen
- 14,948
- 1
- 9
- 18
-
You are right. It's the server timing out. – Vivek Ranjan Dec 17 '20 at 06:30
-
@VivekRanjan Thanks for your vote up, could you please also [mark](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) my answer as "accepted", thanks. – Hury Shen Dec 17 '20 at 06:37