Is it possible to discover services using DNS-SD on client side using some JS library (so to discover services on client's local network)? I found a lot of libraries on npmjs.com, but they all work on Node.js, not on client-side JS.
-
[Not any longer](https://www.w3.org/TR/discovery-api/), no. – Bergi Dec 05 '20 at 21:15
2 Answers
DNS is (historically) a UDP-based protocol. Browsers traditionally sandbox the networking capabilities and allow to send only HTTP or HTTPS (i.e. TCP) requests from JavaScript code. So, the short answer is No.
However, if you truly need this feature, you could look into the DNS-over-HTTPS technology which got some traction recently. Alternatively, you can try searching for ways of sending UDP packets from the browser. I don't have much knowledge in that domain but WebAssembly or WebRTC potentially may have something implemented already.

- 6,348
- 6
- 44
- 90
-
I doubt that DoH works from the browser - the DNS resolver would need to support CORS, and I cannot imagine how it would be used for local service discovery. – Bergi Dec 05 '20 at 21:19
Checkout the sample app in the Chrome Web Store.
mDNS browser This is a non-trivial sample which uses the UDP multicast support in Chrome Packaged Apps to browse mDNS servers. mDNS protocol is usually used for home appliance devices, like the Apple's Bonjour. Read more about the mDNS protocol at this Wikipedia's article
See the source code at https://github.com/GoogleChrome/chrome-app-samples/tree/master/mdns-browser

- 349
- 2
- 10