【发布时间】:2015-06-17 19:57:57
【问题描述】:
我有这个示例 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' }
issue on the mdns GitHub 表示忽略警告是公平的。
但是这两个错误呢?这是我的 Raspberry PI 上的某种配置问题吗?
【问题讨论】:
-
仅供参考,
getaddrinfo错误代码可以使用gai_strerror转换为人类可读的文本,在netdb.h中定义。不幸的是,错误代码 -3008 表示为“未知错误”。我的猜测是错误代码来自getaddrinfo函数以外的其他地方,可能是一些底层系统调用或其他... -
树莓派上运行的是哪个版本的node.js?
标签: node.js raspberry-pi raspbian mdns raspberry-pi2