demille / dnssd.js Goto Github PK
View Code? Open in Web Editor NEWBonjour/Avahi-like service discovery in pure JavaScript
License: MIT License
Bonjour/Avahi-like service discovery in pure JavaScript
License: MIT License
An example of what I mean, the callback of a browse of the network logs "topic" as undefined
const fooServiceType = new dnssd.ServiceType({ name: '_mqtt', protocol: '_tcp', topic: 'topic3' });
Line 40 in d66f0dd
Examples use resolveA
and resolveAAAA
, but in the source they're named resolve4
and resolve6
.
Error: send ENETUNREACH 224.0.0.251:5353
at doSend (node:dgram:705:16)
at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
at afterDns (node:dgram:651:5)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:533:9)
at process.processTimers (node:internal/timers:507:7) {
errno: -101,
code: 'ENETUNREACH',
syscall: 'send',
address: '224.0.0.251',
port: 5353
}
So we can not use library with browser and advertiser on the same machine
I am using Node v10.11.0.
I’ve seen that the interval in sleep.js is unref()
ed to allow the process to end, however, this does not seem to work for me.
const dnssd = require('dnssd');
const ad = new dnssd.Advertisement(dnssd.tcp('http'), 4321);
console.log('starting...');
ad.start();
console.log('started');
console.log('stopping...');
ad.stop(false, (err) => {
if (err) throw err;
console.log('stopped');
});
When running this script, the process will not exit for me.
I use webthing
which uses dnssd
via NPM.
After completing tests in a repository of mine Jest has to be force exited for the process to quit.
git clone [email protected]:webthings/all-webthings.git
cd all-webthings
git checkout cf92a899d376ca48411b56f04ca0c2915a41d2ba
npm test -- --detectOpenHandles
This output the following on my machine:
Ran all test suites.
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● Timeout
at Object.<anonymous> (node_modules/dnssd/lib/sleep.js:14:16)
at Object.<anonymous> (node_modules/dnssd/lib/Advertisement.js:14:13)
resolveA and resolveAAAA mentioned in the readme seem to be missing:
$ node
> require('./')
{ Advertisement: [Function: Advertisement],
Browser: [Function: Browser],
ServiceType: [Function: ServiceType],
tcp: [Function: tcp],
udp: [Function: udp],
all: [Function: all],
validate:
{ protocol: [Function: protocol],
serviceName: [Function: serviceName],
label: [Function: label],
port: [Function: port],
txt: [Function: txt] },
resolve: [Function: resolveAny],
resolveA: undefined, <---------------
resolveAAAA: undefined, <---------------
resolveSRV: [Function: resolveSRV],
resolveTXT: [Function: resolveTXT],
resolveService: [Function: resolveService] }
I assume they are meant to use
Lines 81 to 91 in 3fd30a7
resolveSRV
and resolveTXT
.Hi,
we have an embedded system with a number of interfaces - eth0, wlan0, bat0 - to name a few.
The following code runs
var DNSSD = require("dnssd");
let _dnsdsBrowser = new DNSSD.Browser(DNSSD.tcp('_mqtt'));
let _dnsdsAdvMqtt = new DNSSD.Advertisement(DNSSD.tcp('_funky'), 2883, { name: 'FUNKY' });
let _dnsdsAdvMqttWS = new DNSSD.Advertisement(DNSSD.tcp('_funky-ws'), 3001, { name: 'FUNKY WS' });
_dnsdsAdvMqtt.start();
but the services show up only on the first interface that has been detected (eth0 in our case, where we don't want it ... ) -- not even at localhost.
How can we make sure it is accessible from the other network participants?
Simon
There are some artifacts of a merge conflict left behind:
https://github.com/DeMille/dnssd.js/blob/master/lib/NetworkInterface.js#L247
Sorry for shouting, checking if there is somebody listening.
When an interface has been changed to a different network, it can use a stale multicast address, resulting in an EADDRNOTAVAIL error.
Expected: the interface uses the multicast address for the current network
Actual: the interface uses the multicast address for the first network it saw
Steps to reproduce:
An error like this is thrown:
Error: setMulticastInterface EADDRNOTAVAIL
at Socket.setMulticastInterface (dgram.js:566:11)
at Socket.eval (webpack:///./node_modules/dnssd/lib/NetworkInterface.js?:238:41)
at Socket.emit (events.js:182:13)
at startListening (dgram.js:128:10)
at state.handle.lookup (dgram.js:249:7)
at process._tickCallback (internal/process/next_tick.js:63:19)
When I specify host
as a FQDN, it gets renamed improperly.
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[32m•Advertise…#033[0m #033[9
0m[11:43:07:338]#033[0m Hostname renamed to "somehost.mydomain.net (2)" on int
erface records
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[34m•ResourceR…#033[0m #033[90m[11:43:07:295]#033[0m Found conflict:
Jul 27 11:43:07 wilhelm signalk-server[23344]: Record: somehost.mydomain.net.local. #033[34mA#033[0m 120 192.168.1.200 #033[90m(flush)#033[0m
Jul 27 11:43:07 wilhelm signalk-server[23344]: Incoming: somehost.mydomain.net.local. #033[34mA#033[0m 120 192.168.1.122 #033[90m(flush)#033[0m
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[34m•ResourceR…#033[0m #033[90m[11:43:07:295]#033[0m Found conflict:
Jul 27 11:43:07 wilhelm signalk-server[23344]: Record: somehost.mydomain.net.local. #033[34mAAAA#033[0m 120 fe80::d056:37ff:fe54:903e #033[90m(flush)#033[0m
Jul 27 11:43:07 wilhelm signalk-server[23344]: Incoming: somehost.mydomain.net.local. #033[34mAAAA#033[0m 120 fe80::210a:8e62:baf3:12e #033[90m(flush)#033[0m
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[35m•Probe.js #033[0m #033[90m[11:43:07:296]#033[0m Found conflict on incoming records (id#2)
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[35m•Probe.js #033[0m #033[90m[11:43:07:297]#033[0m Probe stopped (id#2)
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[36m•Responder…#033[0m #033[90m[11:43:07:298]#033[0m Sending stop signal to actives. (id#2)
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[36m•Responder…#033[0m #033[90m[11:43:07:298]#033[0m Had a conflict with "somehost.mydomain.net", renaming. (id#2)
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[36m•Responder…#033[0m #033[90m[11:43:07:303]#033[0m Now probing for: somehost.mydomain.net (2).local.
Jul 27 11:43:07 wilhelm signalk-server[23344]: #033[36m•Responder…#033[0m #033[90m[11:43:07:303]#033[0m Sending probes for "somehost.mydomain.net (2).local.". (id#2)
Hi, Does this project match all requirements by the Apple BonjourConformanceTest?
thank u
There is a TXT record key validation rule that limits the length of a key to 9 characters.
As far as I know, there is no such limitation in DNS-SD RFC. Both Apple and Avahi implementations
does not restrict key lengths.
This validation rule should be removed.
The servicetypes passed in the options parameter while creating an advertisement are ignored.
const dnssd = require('dnssd');
const ad = new dnssd.Advertisement(dnssd.tcp('http'), 4321, { subtypes: ['printer'] });
ad._makeServiceRecords()
Should contain the printer._sub._http._tcp.local.
PTR-Record.
Creating it with your a new ServiceType works as expected.
const dnssd = require('dnssd');
const ad = new dnssd.Advertisement(new dnssd.ServiceType('_http._tcp,printer'), 4321);
ad._makeServiceRecords()
I'm getting a strange error when I use the library in a built project (using esbuild
).
The error is: ResourceRecord2 is not a constructor
Anyone seeing this as well?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.