Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raspberry PI mdns getaddrinfo 3008 error

I've this sample Node.js script:

var mdns = require('mdns');

var browser = mdns.createBrowser(mdns.tcp('http'));
browser.on('error', function (error) {
    console.log("error");
    console.log(error);
});
browser.on('serviceUp', function (service) {
    console.log("serviceUp");
    console.log(service);
});
browser.start();

On my Mac it's working fine, and two services is found. If I run the exact same script on my Raspberry PI 2 running Raspbean (connected to the same network), I get this output:

pi@raspberrypi ~ $ node mdns.js 
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
error
{ [Error: getaddrinfo -3008] code: -3008, errno: -3008, syscall: 'getaddrinfo' }
error
{ [Error: getaddrinfo -3008] code: -3008, errno: -3008, syscall: 'getaddrinfo' }

A issue on the mdns GitHub, states that it's fair to ignore the warnings.

But what about the two errors? Is that some kind of configuration issue on my Raspberry PI?

like image 724
dhrm Avatar asked Apr 12 '15 12:04

dhrm


2 Answers

A solution was found on this GitHub issue: https://github.com/agnat/node_mdns/issues/130

Modify Browser.defaultResolverSequence inside lib/browser.js in mdns.

Browser.defaultResolverSequence = [
  rst.DNSServiceResolve(), 'DNSServiceGetAddrInfo' in dns_sd ? rst.DNSServiceGetAddrInfo() : rst.getaddrinfo({families:[4]})
, rst.makeAddressesUnique()
];
like image 166
dhrm Avatar answered Oct 29 '22 10:10

dhrm


It's a bad practice to modify node modules code locally.

You should better do the following when you create a mdns Browser:

var sequence = [
  mdns.rst.DNSServiceResolve(),
  'DNSServiceGetAddrInfo' in mdns.dns_sd ? mdns.rst.DNSServiceGetAddrInfo() : mdns.rst.getaddrinfo({families:[4]}),
  mdns.rst.makeAddressesUnique()
];
var browser = mdns.createBrowser(mdns.tcp('http'), {resolverSequence: sequence});

Like said in this comment: https://github.com/agnat/node_mdns/issues/130#issuecomment-120731155

Thus, it will avoid bugs and allow everybody working on the project to get the same version and don't have to modify locally mdns code.

like image 34
Art2B Avatar answered Oct 29 '22 10:10

Art2B