tjfontaine / node-dns

Replacement dns module in pure javascript for node.js
MIT License
585 stars 154 forks source link

dns.Request() timesout if server sends NXDOMAIN (NOTFOUND) #87

Open Esowteric opened 9 years ago

Esowteric commented 9 years ago

Hi, I'm using your dns.Request() method in a DNS load balancing proxy app to check if the DNS servers are responsive.

If the test domain exists, then req.on('message') correctly fires. If a server is down, then req.on('timeout') correctly fires.

However, if I deliberately request a non-existent domain, though my servers respond with NXDOMAIN (NOTFOUND, rcode 3), then req.on('message') is not called, nor is req.on('error'). Instead, req.on('timeout') fires. Hence, I don't get a chance to inspect err or answer (eg to get answer.header.rcode).

Is this the expected behaviour, or am I missing something?

With good wishes, Eric T.

silverwind commented 9 years ago

@Esowteric:

Tried to reproduce, but I did get below message on a NXDOMAIN (verified with dig), which looks correct (rcode 3):

{ header:
   { id: 5537,
     qr: 1,
     opcode: 0,
     aa: 0,
     tc: 0,
     rd: 1,
     ra: 1,
     res1: 0,
     res2: 0,
     res3: 0,
     rcode: 3 },
  question: [ { name: 'thisdomaindoesntexist.com', type: 1, class: 1 } ],
  answer: [],
  authority:
   [ { name: 'com',
       type: 6,
       class: 1,
       ttl: 899,
       primary: 'a.gtld-servers.net',
       admin: 'nstld.verisign-grs.com',
       serial: 1421488204,
       refresh: 1800,
       retry: 900,
       expiration: 604800,
       minimum: 86400 } ],
  additional: [],
  edns_options: [],
  payload: undefined,
  _socket: { address: '8.8.8.8', family: 'IPv4', port: 53, size: 116 } }