3

So I have an Azure Function that calls Microsoft Maps API and it works (sometimes). However at times it throws this error during the request. Please advise.

My Code:

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)

Response/Error:

{
"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"
  }
}
search-learn
  • 1,037
  • 1
  • 9
  • 23

2 Answers2

2

The solution to my timeout problem was adding

host:'atlas.microsoft.com

into my headers for all of my calls. 99% of the connection errors went away. I also reached out to Mircosoft support and they said it doesn't matter if you're using S0 or S1 there is no throttling so that shouldn't make a difference. Currently support is investigating why adding the host part into request headers made such a difference. Will update later with their response.

I asked a similar question and figured out here some additional details.

search-learn
  • 1,037
  • 1
  • 9
  • 23
0

I saw your request url has subscription-key, and I think you don't need options any more.

According to my test, your problem is not reproduced. The pricing tiers of my Azure Maps service is S1. So I guess the possible reason for your problem.

enter image description here

1. pricing tiers.

Suggest: You can change your pricing tiers.

2. The service of Azure Map is abnormal.

Suggest: It is recommended to raise a support ticket in portal, ask if there is any abnormal service in this area, and check your service log.

Below are my test results.

I tested it and my test url like https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&query=seattle&subscription-key=WCzM8k*******nnSYn4. I just request via chrome browser and get response.

enter image description here

And I also test by axios and it works fine.

enter image description here

Jason Pan
  • 15,263
  • 1
  • 14
  • 29
  • I did open a request ticket and a technician is currently looking into it. My calls also work through axios, but its not consistent. Sometimes it doesn't work, for the same request. I even ran a test by making 100 identical calls and 4 of them failed with that ^ error. In no particular order either. I will look into the pricing tiers to see if their are concurrency limits or some quotas I am not aware of. – search-learn Jul 16 '20 at 03:48
  • @search-learn Ok, if there is a professional reply from the official technical staff, I look forward to sharing with you. – Jason Pan Jul 16 '20 at 05:34