我有这个示例 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' }
mdns GitHub 上的一个问题指出,忽略警告是公平的。
但是这两个错误呢?这是我的Raspberry PI上的某种配置问题吗?