bonjour icon indicating copy to clipboard operation
bonjour copied to clipboard

Bonjour can find services that it created itself, but nothing else can

Open MarshallOfSound opened this issue 8 years ago • 13 comments

Running the following in my app

const service = bonjour.publish({
  type: 'GPMDP',
  name: os.hostname(),
  port: 5672,
  txt: {
    API_VERSION,
  },
});

service.start();

The up event is fired for service but when I attempt to find the published service with this chrome app https://chrome.google.com/webstore/detail/mdns-browser/kipighjpklofchgbdgclfaoccdlghidp

It is not there. Is there some configuration step I am missing, or is there a trick to getting this to run on a device that already has Apple Bonjour running?

MarshallOfSound avatar May 18 '16 23:05 MarshallOfSound

@MarshallOfSound It might be related to which interface it tries to bind to. It should bind to all network interfaces, but maybe it doesn't. Do you mind showing me your os.networkInterfaces() configuration?

watson avatar May 19 '16 07:05 watson

You can take a look, there are a few interfaces there though :smile:

{
  "VirtualBox Host-Only Network #2":[
    {
      "address":"2620:9b::1922:5b34",
      "netmask":"ffff:ffff:ffff:ffff::",
      "family":"IPv6",
      "mac":"0a:00:27:00:00:00",
      "scopeid":0,
      "internal":false
    },
    {
      "address":"fe80::5c1a:317d:78e0:8d3c",
      "netmask":"ffff:ffff:ffff:ffff::",
      "family":"IPv6",
      "mac":"0a:00:27:00:00:00",
      "scopeid":4,
      "internal":false
    },
    {
      "address":"169.254.141.60",
      "netmask":"255.255.0.0",
      "family":"IPv4",
      "mac":"0a:00:27:00:00:00",
      "internal":false
    }
  ],
  "Ethernet":[
    {
      "address":"2001:388:608c:6cb4:29b4:1aad:ca61:f3fa",
      "netmask":"ffff:ffff:ffff:ffff::",
      "family":"IPv6",
      "mac":"fc:aa:14:28:ac:a3",
      "scopeid":0,
      "internal":false
    },
    {
      "address":"2001:388:608c:6cb4:8c17:17c8:9aa3:e543",
      "netmask":"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
      "family":"IPv6",
      "mac":"fc:aa:14:28:ac:a3",
      "scopeid":0,
      "internal":false
    },
    {
      "address":"fe80::29b4:1aad:ca61:f3fa",
      "netmask":"ffff:ffff:ffff:ffff::",
      "family":"IPv6",
      "mac":"fc:aa:14:28:ac:a3",
      "scopeid":9,
      "internal":false
    },
    {
      "address":"118.138.193.83",
      "netmask":"255.255.252.0",
      "family":"IPv4",
      "mac":"fc:aa:14:28:ac:a3",
      "internal":false
    }
  ],
  "Loopback Pseudo-Interface 1":[
    {
      "address":"::1",
      "netmask":"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
      "family":"IPv6",
      "mac":"00:00:00:00:00:00",
      "scopeid":0,
      "internal":true
    },
    {
      "address":"127.0.0.1",
      "netmask":"255.0.0.0",
      "family":"IPv4",
      "mac":"00:00:00:00:00:00",
      "internal":true
    }
  ],
  "Teredo Tunneling Pseudo-Interface":[
    {
      "address":"2001:0:9d38:90d7:2466:1cd1:8975:3eac",
      "netmask":"ffff:ffff:ffff:ffff::",
      "family":"IPv6",
      "mac":"00:00:00:00:00:00",
      "scopeid":0,
      "internal":false
    },
    {
      "address":"fe80::2466:1cd1:8975:3eac",
      "netmask":"ffff:ffff:ffff:ffff::",
      "family":"IPv6",
      "mac":"00:00:00:00:00:00",
      "scopeid":24,
      "internal":false
    }
  ]
}

MarshallOfSound avatar May 19 '16 07:05 MarshallOfSound

@watson It appears to be due to bonjour not responding to a _services._dns-sd._udp.local QUERY

https://developer.apple.com/library/mac/qa/qa1337/_index.html

MarshallOfSound avatar May 19 '16 15:05 MarshallOfSound

Seems to work fine for me @MarshallOfSound, try using an mDNS browser app on your phone to verify.

jostrander avatar May 20 '16 01:05 jostrander

@MarshallOfSound ah yes, that might also be it. I have a local fix for it that depends on something being fixed first in a dependency that I've been putting off for too long now. I'll see if I can get it fixed in the weekend. Thanks for letting me know about this 😃

watson avatar May 20 '16 08:05 watson

@watson Is there any progress on this, is there anything I can do to help? :smile_cat:

MarshallOfSound avatar May 31 '16 03:05 MarshallOfSound

@watson is there any chance for this fix? I find this package to have the best api, but I cannot discover services (that were published on PC using bonjour) on an Android phone using NSD. However the services registered by Android phone are visible on PC.

Keammoort avatar Jul 21 '16 07:07 Keammoort

hi guys, i published a service and detection from an android app was a success but not frm the chrome mdns browser ? any fix guys ?

haddadnidal avatar Jul 30 '16 14:07 haddadnidal

looks like a dead end @watson do you think you are going to provide the relevant fix ?

Thanks !

gabrielstuff avatar Sep 06 '16 09:09 gabrielstuff

+500 on this, can't detect a service on my mac (dns-sd -B) that I've published on my windows machine. Works fine when publishing via dns-sd. Also I can see the announcement on the same machine but not on any other device.

/btw, opts.probe ain't seem to be documented

@MarshallOfSound have you found a fix? How have you worked around this? Are you using some other solution?

@watson Are you still maintaining this project? Would love to see a fix / contribute.

black-snow avatar Dec 13 '16 20:12 black-snow

The service announcement in this example, and by default if not specified, uses "os.hostname()" as the host for the service. This must have ".local" at the end to work, but that's certainly not the case for some Linux installs - I would go so far as to say most Linux installs. Without this, the service is announced but isn't resolvable to a host.

On my setup here (a minimal Ubuntu install), this was fixed by changing the line in service.js from:

this.host = opts.host || os.hostname();

to something like:

var oshost = os.hostname();
if (oshost.indexOf(".") < 0) {
    oshost  += ".local";
}
this.host = opts.host || oshost;

No pull request as I'm not sure how this will work on different combinations of client and server OS, but it's fixed this issue for me with a Linux server and Mac client.

faceless2 avatar Sep 05 '17 22:09 faceless2

Piggybacking on @faceless2's answer: I had the same issue on Ubuntu running in a VM, although I was using HTTP.

Added the host parameter specifying the .local suffix. Something like: bonjour.publish({ name: 'my_server', host: 'woopboop.local', type: 'http', port: 3000 }) instead of bonjour.publish({ name: 'my_server', type: 'http', port: 3000 })

Pinging woopboop.local from my terminal worked after this. Hope it helps.

VanTudor avatar Sep 21 '20 15:09 VanTudor

I went with https://github.com/agnat/node_mdns and that worked from the get-go

Vannevelj avatar Nov 14 '20 14:11 Vannevelj