Bonjour Discovery in Javascript? Maybe?
Asked Answered
D

5

25

So its a longshot, I'll start with that.

Is it/could it be possible to discover bonjour advertised HTTP services in javascript alone?

Why would this be useful? Imagine a local service looking after some data (eg your current lat/long), the data is exposed via a webservice and advertised by Bonjour Zeroconf. A (remote) website might want to know your current lat/long and rather than having to know you're running MyGPSserverVersion2 the site could use javascript to search the local bonjour for _Compatible_location_services._tcp and then continue once it had an IP address.

If this is impossible (I think its probably the case, Javascript is fairly restricted) then what are the hurdles and does anyone have any ideas as to how to overcome them?

Devilish answered 1/12, 2009 at 19:10 Comment(0)
L
6

This seems to be possible using the Chrome's Sockets API, but I've only taken a cursory look.

mdns-browser seems to implement this using said APIs.

Locomobile answered 9/3, 2013 at 10:32 Comment(4)
The sockets API is only exposed to chrome apps and not to JS code running in browser.Aviatrix
Be aware that Chrome Apps have been deprecated by Google: blog.chromium.org/2016/08/from-chrome-apps-to-web.htmlNadabb
mans-browser code is now under github.com/GoogleChrome/chrome-extensions-samples/tree/master/…Matte
"This item can only run on ChromeOS"Perilymph
I
9

The short answer is no ( at least not on the Linux platform ).

Funny you should ask: I have been working on bringing this sort of functionality within reach of web browsers. One of my success in this endeavor is an NPAPI mDNS plugin for Chrome. The plugin basically interfaces with Avahi ZeroConf (mDNS - Multicast DNS Server).

I am currently working on yet another bridge to close this gap: a "lightweight" database ( a la CouchDb ) that will be used by desktop applications to register their HTTP end-points. Extensions would then read those end-points from Javascript and be able to interact directly with the advertised services.

UPDATE: There is hope through W3C Service Discovery.

Isaak answered 1/12, 2009 at 19:25 Comment(2)
That sounds like it could be really useful! Could you be convinced to formalize the service? I reckon I could whip up an external ruby app that would provide the same service on Mac OS - it'd be an extra bit of cruft to keep running, but it'd be available to all browsers.Devilish
There is no hope throught W3C Service Discovery any more: " Work on this document has been discontinued and it should not be referenced or used as a basis for implementation. The Presentation API and the Remote Playback API address a subset of the use cases this API attempted to address. " The subset of use cases does not include service discovery.Crocker
L
6

This seems to be possible using the Chrome's Sockets API, but I've only taken a cursory look.

mdns-browser seems to implement this using said APIs.

Locomobile answered 9/3, 2013 at 10:32 Comment(4)
The sockets API is only exposed to chrome apps and not to JS code running in browser.Aviatrix
Be aware that Chrome Apps have been deprecated by Google: blog.chromium.org/2016/08/from-chrome-apps-to-web.htmlNadabb
mans-browser code is now under github.com/GoogleChrome/chrome-extensions-samples/tree/master/…Matte
"This item can only run on ChromeOS"Perilymph
I
0

This library claims to do it in Javascript : http://quickconnect.sourceforge.net/browser/index.html

I have to admit that I would be very interested if it was possible to discover bonjour services in javascript :)

Indiana answered 28/4, 2011 at 12:56 Comment(1)
I had a look at this and it still uses some Objective-C to expose the iOS Bonjour functions to Javascript.Mown
M
0

I know this an old thread. Found this github project which allows you to discover (and publish) services using mDNS - https://github.com/watson/bonjour

A Bonjour/Zeroconf protocol implementation in pure JavaScript. Publish services on the local network or discover existing services using multicast DNS.

Meany answered 13/4, 2017 at 22:47 Comment(1)
this library is not supported on browsers: github.com/watson/bonjour/issues/33Hybrid
S
0

Here's the modern fork of the watson/bonjour javascript code. This one's in TypeScript.

https://github.com/onlxltd/bonjour-service

Of course, this only works from a command line node app, not from a web page.

Subglacial answered 23/7, 2021 at 14:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.