Raspberry PI mdns getaddrinfo 3008错误

时间:2015-04-12 12:38:18

标签: node.js raspberry-pi raspbian mdns raspberry-pi2

我有这个示例Node.js脚本:

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();

在我的Mac上,它工作正常,找到了两项服务。如果我在运行 Raspbean (连接到同一网络)的 Raspberry PI 2 上运行完全相同的脚本,我会收到此输出:

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,声明忽略警告是公平的。

但是这两个错误呢?这是我的 Raspberry PI 上的某种配置问题吗?

2 个答案:

答案 0 :(得分:5)

在本地修改节点模块代码是一种不好的做法。

创建mdns浏览器时,最好执行以下操作:

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});

像评论中所说:https://github.com/agnat/node_mdns/issues/130#issuecomment-120731155

因此,它将避免错误并允许每个在项目上工作的人获得相同的版本,并且不必修改本地的mdns代码。

答案 1 :(得分:2)

在此GitHub问题上找到了一个解决方案: https://github.com/agnat/node_mdns/issues/130

在mdns中修改 lib / browser.js 中的 Browser.defaultResolverSequence

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