Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 获取Axios HTTP Get请求的connect-ETIMEDOUT_Node.js_Http_Axios_Azure Functions - Fatal编程技术网

Node.js 获取Axios HTTP Get请求的connect-ETIMEDOUT

Node.js 获取Axios HTTP Get请求的connect-ETIMEDOUT,node.js,http,axios,azure-functions,Node.js,Http,Axios,Azure Functions,因此,我有一个Azure函数,它调用MicrosoftMapsAPI,并且(有时)可以正常工作。但是,在请求过程中,它有时会抛出此错误。请告知 我的代码: const options = { host: 'atlas.microsoft.com', //added this later headers: { 'x-ms-client-id': client_id } } //url to get lat/long let url = 'https://atlas.microsof

因此,我有一个Azure函数,它调用MicrosoftMapsAPI,并且(有时)可以正常工作。但是,在请求过程中,它有时会抛出此错误。请告知

我的代码:

const options = 
{
   host: 'atlas.microsoft.com', //added this later
   headers: { 'x-ms-client-id': client_id }
}

//url to get lat/long
let url = 'https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&subscription-key=' + subscription_key + '&query=' + address + ' USA'

//make req
let res = await axios.get(url, options)
答复/错误:

{
"error": {
"message": "connect ETIMEDOUT XX.XXX.XX.XX:XXX",
"name": "Error",
"stack": "Error: connect ETIMEDOUT XX.XXX.XX.XX:XXX\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)",
"config": {
  "url": "https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&subscription-key=myKey&query=myQuery",
  "method": "get",
  "headers": {
    "Accept": "application/json, text/plain, */*",
    "x-ms-client-id": myClientID,
    "User-Agent": "axios/0.19.2"
  },
  "transformRequest": [
    null
  ],
  "transformResponse": [
    null
  ],
  "timeout": 0,
  "xsrfCookieName": "XSRF-TOKEN",
  "xsrfHeaderName": "X-XSRF-TOKEN",
  "maxContentLength": -1,
  "host": "atlas.microsoft.com"
},
"code": "ETIMEDOUT"
  }
}

我看到您的请求url具有
订阅密钥
,我认为您不再需要
选项

根据我的测试,你的问题不会重现。my Azure地图服务的定价层为S1。所以我猜你的问题的可能原因

1。定价层级。

建议:您可以更改定价层级

2。Azure地图服务异常。

建议:建议在门户中提交支持票证,询问此区域是否有异常服务,并检查您的服务日志

以下是我的测试结果。

我测试了它和我的测试url,比如
https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&query=seattle&subscription key=WCzM8k*******nnSYn4
。我只是通过chrome浏览器请求并得到响应

我还通过
axios
进行了测试,效果很好


我的超时问题的解决方案是添加

host:'atlas.microsoft.com
进入我所有通话的标题。99%的连接错误消失了。我还联系了Mircosoft的支持人员,他们说,无论您使用的是S0还是S1,都没有节流功能,所以不会有什么不同。目前,支持部门正在调查为什么将主机部件添加到请求头中会产生如此大的差异。稍后将更新他们的答复


我问了一个类似的问题,并找出了一些额外的细节。

我确实打开了一张申请单,一位技术人员正在调查。我的通话也可以通过axios进行,但并不一致。对于同一个请求,有时它不起作用。我甚至做了一个测试,打了100个相同的电话,其中4个失败了。也没有特别的顺序。我将调查定价层,看看它们是并发限制还是一些我不知道的配额。@search learn Ok,如果有官方技术人员的专业回复,我期待与您分享。