Quantcast
Channel: dns.resolveCname fails when there are large amounts of CNAMEs to be resolved - Stack Overflow
Viewing all articles
Browse latest Browse all 2

dns.resolveCname fails when there are large amounts of CNAMEs to be resolved

$
0
0

I'm writing a program to resolve about 10,000 CNAMEs.

The problem I have is that dns.resolveCname() returns Error: queryCname ESERVFAIL error when the number of CNAMEs to be resolved gets too large.

The code looks like the following:

const dns = require('dns')
dns.setServers(['8.8.8.8']) // provided by google

let cnames = [....] // length of cnames is 10,000
let promiseArr = []

for (let i = 0; i < cnames.length; i += 1) {
  let p = new Promise((resolve, reject) => {
    dns.resolveCname(cnames[i], (err, records) => {
      if (err) {
        console.log(err)  // this line generates Error: queryCname ESERVFAIL
        resolve()         // sorry, I forgot adding this line.
      } else {
        console.log(records)
        resolve()         // sorry, I forgot adding this line.
      }
    })
  })
  promiseArr.push(p)
}

Promise.all(promiseArr)
.then(value => {
  console.log(`Promise.all done`)
})
.catch(err => {
  console.log(`promise err: ${err}`)
})

Does it mean that I cannot use dns.resolveCname() too frequently?

Is it possible to avoid this problem by decreasing the frequency I trigger dns.resolveCname()?

Or are there any other ways I can overcome this problem?

I'm using node.js v6.2.2.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>