Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: dns service error: no such record #181

Closed
hugovk opened this issue Nov 25, 2016 · 7 comments
Closed

Error: dns service error: no such record #181

hugovk opened this issue Nov 25, 2016 · 7 comments

Comments

@hugovk
Copy link

hugovk commented Nov 25, 2016

Node 7.1.0
mdns 2.3.3

chromecast-osx-audio uses this mdns library, and I'm getting this error (see also: fardog/node-chromecast-osx-audio#11):

  1. Install with npm install -g chromecast-osx-audio
  2. On the command line, run chromecast -l

Actual result:

Devices available for casting:
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: dns service error: no such record
    at Error (native)
    at MDNSService.on_get_addr_info_done (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/resolver_sequence_tasks.js:72:30)
    at SocketWatcher.MDNSService.self.watcher.callback (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/mdns_service.js:18:40)

Expected result:

Devices available for casting:
Chromecast-[an ID number]
Chromecast-Audio-[an ID number]

I've managed to hack it to work by editing /usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/resolver_sequence_tasks.js:72:30

and changing:

          if (error) {
            adr_getter.stop()
            next(error);
          } else {

to:

          if (false) {
            adr_getter.stop()
            next(error);
          } else {

But it'd be nice to fix it properly.


chromecast-osx-audio calls mdns here: https://github.com/fardog/node-chromecast-osx-audio/blob/master/lib/chromecast.js

Here's a simplified version:

var mdns = require('mdns');
var browser = mdns.createBrowser(mdns.tcp('googlecast'));
browser.on('serviceUp', function(service) {
  console.log("service up: ", service);
});
browser.on('serviceDown', function(service) {
  console.log("service down: ", service);
});
browser.on('error', function(service) {
  console.log("error: ", error);
});
browser.start();

If I run it in Node's REPL:

> var mdns = require('mdns');
undefined
> var browser = mdns.createBrowser(mdns.tcp('googlecast'));
undefined
> browser.on('serviceUp', function(service) {
...   console.log("service up: ", service);
... });
Browser {
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] },
  _events: { serviceUp: [Function] },
  _eventsCount: 1,
  _maxListeners: undefined,
  _watcherStarted: false,
  serviceRef: DNSServiceRef { initialized: true, fd: 15 },
  watcher: SocketWatcher { host: [Circular], callback: [Function] } }
> browser.on('serviceDown', function(service) {
...   console.log("service down: ", service);
... });
Browser {
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] },
  _events: { serviceUp: [Function], serviceDown: [Function] },
  _eventsCount: 2,
  _maxListeners: undefined,
  _watcherStarted: false,
  serviceRef: DNSServiceRef { initialized: true, fd: 15 },
  watcher: SocketWatcher { host: [Circular], callback: [Function] } }
> browser.start();
undefined
> Error: dns service error: no such record
    at MDNSService.on_get_addr_info_done (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/resolver_sequence_tasks.js:72:30)
    at SocketWatcher.MDNSService.self.watcher.callback (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/mdns_service.js:18:40)

I have just one Chromecast on the network at the moment, but when adding extra logging to on_get_addr_info_done(sdRef, flags, iface, errorCode, hostname, address, context) in resolver_sequence_tasks.js:

          var error = dns_sd.buildException(errorCode);
          console.log("--------------")
          console.log("sdRef:", sdRef, "flags:", flags, "iface:", iface, "errorCode:", errorCode, "hostname:", hostname, "address:", address, "context:", context);
          console.log(error);
          console.log("--------------")
          if (error) {

it gives:

> browser.start();
undefined
> --------------
sdRef: DNSServiceRef { initialized: true, fd: 16 } flags: 3 iface: 5 errorCode: 0 hostname: 3a3e4359-41d7-9ae1-e540-60f1594029a7.local. address: 192.168.1.214 context: 120
undefined
--------------
--------------
sdRef: DNSServiceRef { initialized: true, fd: 16 } flags: 2 iface: 0 errorCode: -65554 hostname: 3a3e4359-41d7-9ae1-e540-60f1594029a7.local. address: :: context: 60
{ Error: dns service error: no such record
    at MDNSService.on_get_addr_info_done (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/resolver_sequence_tasks.js:72:30)
    at SocketWatcher.MDNSService.self.watcher.callback (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/mdns_service.js:18:40) errorCode: -65554 }
--------------
Error: dns service error: no such record
    at MDNSService.on_get_addr_info_done (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/resolver_sequence_tasks.js:72:30)
    at SocketWatcher.MDNSService.self.watcher.callback (/usr/local/lib/node_modules/chromecast-osx-audio/node_modules/mdns/lib/mdns_service.js:18:40)

So the same service is coming through twice, with no error the first time, but "Error: dns service error: no such record" (-65554) and different flags, iface and context the second time.

Any idea what's the problem? Thanks!

@mooyoul
Copy link

mooyoul commented Nov 26, 2016

I just encountered same issue, this issue was really weird.

I connected my home network via OpenVPN TAP (note that is NOT TUN device) on my macOS. because i want to connect airplay capable devices on outside places even i'm away from home to develop airplay related package at coffee shop (cafe).

Every discovery attempts are failed quickly, and i can't discover any services. but macOS displays my Airplay devices correctly (see below screenshot), and i can see mdns query/response packets on Wireshark. Packets seems okay.

2016-11-27 5 11 27

2016-11-27 5 13 08

Interesting point is when i made OpenVPN connection via iPhone USB Tethering, This issue appears, but when makes OpenVPN connection via iPhone Wi-Fi Tethering, this issue are gone.

@agnat
Copy link
Owner

agnat commented Dec 1, 2016

Hi @hugovk

what OS is this on? Assuming this is on linux it looks like a resolver issue. It's complicated but it often boils down to providing a custom resolver chain that handles ipV6 differently. Look at other applications using mdns.

Note, that unlike your example the production code does not register an error handler.

@agnat
Copy link
Owner

agnat commented Dec 1, 2016

@mooyoul this seems to involve mDNS across a network gateway. Please file a separate issue and provide more information about the environment ... like the OS and such, not the coffee shop.

@hugovk
Copy link
Author

hugovk commented Dec 1, 2016

@agnat Thanks for the pointers. I'm using macOS Sierra.

I found this code in a few applications using mdns:

mdns.Browser.defaultResolverSequence[1] = 'DNSServiceGetAddrInfo' in mdns.dns_sd
  ? mdns.rst.DNSServiceGetAddrInfo()
  : mdns.rst.getaddrinfo({families:[4]});

Putting that at the top of chromecast-osx-audio's chromecast.js still results in "Error: dns service error: no such record".

However, even though 'DNSServiceGetAddrInfo' in mdns.dns_sd is true, if I instead just call mdns.Browser.defaultResolverSequence[1] = mdns.rst.getaddrinfo({families:[4]}); it works...

@agnat
Copy link
Owner

agnat commented Dec 2, 2016

On OS X mdns.rst.DNSServiceGetAddrInfo is the preferred resolver. mdns.rst.getaddrinfo is the hacky linux resolver. Even though it works I'd recommend to debug the underlying issue.

I'll test on sierra as soon as possible, but my gut feeling is that it is a local issue. My feeling is it has to do with ipV6 addresses. Try adding a few console.log(...) to see what is being resolved and try disabling ipV6.

@hugovk
Copy link
Author

hugovk commented Dec 2, 2016

Fixed it! Or at least discovered how to make it work by updating my config and without hacking code.

Quick test with networksetup -setv6off Wi-Fi gives the same error for chromecast -l, and again after networksetup -setv6automatic Wi-Fi.

With it enabled and disabled, http://test-ipv6.com gave 0/10:

Your IPv4 address on the public Internet appears to be [snip]

No IPv6 address detected

Good news! Your current configuration will continue to work as web sites enable IPv6.

You appear to be able to browse the IPv4 Internet only. You will not be able to reach IPv6-only sites.

Your DNS server (possibly run by your ISP) appears to have IPv6 Internet access.

I logged into my router, enabled IPv6 for the LAN, and now http://test-ipv6.com gives 10/10:

Your IPv4 address on the public Internet appears to be [snip]

Your IPv6 address on the public Internet appears to be [snip]

It appears that you use a managed tunnel mechanism, 6RD, to transport IPv6 over IPv4.

Good news! Your current configuration will continue to work as web sites enable IPv6.

Your DNS server (possibly run by your ISP) appears to have IPv6 Internet access.

chromecast -l successfully returns the list of Chromecasts.

  • If I disable IPv6 with networksetup -setv6off Wi-Fi, I get the error again.
  • If I enalbe IPv6 with networksetup -setv6automatic Wi-Fi, it works.

Ideally, it would be good for the application's code to work in the old config, but this is good enough for me.

Thanks for the help!

@stgarf
Copy link

stgarf commented Dec 28, 2016

@agnat Please take a look 👍 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants