node.js - Nodejs azure函数应用程序错误: connect ETIMEDOUT ipaddress:443

标签 node.js azure axios azure-function-app

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); 
}

最佳答案

我用与你相同的代码进行测试,它在我这边工作得很好。代码行 axoisInstance.defaults.timeout = 120000; 有效。所以很可能是服务器端超时设置小于2分钟。

如果错误是由您在代码axoisInstance.defaults.timeout = 120000;中设置的客户端超时引起的,它将显示类似Exception:Error:超过120000ms的超时 (我使用设置 60000 超时进行测试并提供下面的屏幕截图)。但您的错误消息是 Error: connect ETIMEDOUT 'ip address of endpoint':443enter image description here

关于node.js - Nodejs azure函数应用程序错误: connect ETIMEDOUT ipaddress:443,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65247643/

相关文章:

api - 使用Axios进行API调用时Express中的错误处理

javascript - 从字符串中提取有效日期

node.js - 如何多次点击同一个元素而不嵌套? (Selenium-Webdriver + NodeJS + Mocha)

javascript - 使用 Ajax 调用在服务器上实时更新页面

azure - 使用 Bicep 创建 Azure 资源组

reactjs - PropType.shape({}) 失败警告 : Invalid Type

javascript - nodejs 流可读卡在第一个可读对象

azure - 从 Terraform 在 Azure 存储帐户中设置 CORS

node.js - Bot Framework Node.js 发送给特定用户的临时消息

reactjs - 取消路由更改请求(React/Redux/Axios)