agnat/node_mdns

how can mdns discover express server of centos7

Closed this issue · 2 comments

1.express code:
var mdns = require('mdns')
,express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('Hello World');
});
var server= app.listen(3000, function() {
console.log('Listening on port', 3000);
});
2. mdns example code:
var mdns = require("mdns");
var browser = mdns.createBrowser(mdns.tcp('http'));
browser.on('serviceUp', function(service) {
console.log("service up: ", service);
});
browser.on('serviceDown', function(service) {
console.log("service down: ", service);
});
browser.start()

3.when i run express code, the mdns code console.log nothing output. so, i do not konw how to be associated with both, what is the mdns execute environment, and what server should i write to connect mdns server ,and to pub/sub message between two servers

agnat commented

You need to create an mdns.Advertisement on the http server side. See the README and the user guide. Thanks.

like this:
1.var mdns = require('mdns')
,express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('Hello World');
});

var listener = app.listen(4321, function() {
console.log('Listening on port', 4321);
ad = mdns.createAdvertisement(mdns.tcp('http'), 4321);
ad.start();
});

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

3.express http server output:
*** 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
Listening on port 4321

4.mdns server output:
*** 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

5.have no service output, and i don`t konw the user guide "Before we begin go to the internet and get you a bonjour browser so that you can ALL the service discovery." to tell me what should i can do , please tell me how to test two server connect , very thanks