Open capJavert opened 2 years ago
After additional testing I found out that my service will be discovered if the up
event happens while browser is searching for services eg:
bonjour.find
bonjour.publish
up
callback is triggeredIf the publish happens before search is initiated the service never gets discovered.
Hi @capJavert, out of interest, if you restart both machines then start Service.js
followed by Client.js
does it work?
Nope
Interesting, we've been unable to replicate this issue across two Macs on a network. We personally use the publish then find method in another project, cross platform with out any issue so I'm wondering if this is a setup specific issue.
I'll leave this open for now and update if we find anything. Thanks
If you need any more info from me or you have questions about the setup please do tell. I am open to dig into this.
I just had a similar problem: My Windows PC would detect devices on the network (Blackmagic ATEMs and HyperDecks) if I disconnect those devices from the network and reconnect them or if I repower them. However, if I just start the bonjour browser with the devices already running, they would not be found.
Strangely, I could solve this problem by restarting the Windows machine... I have no idea what causes this ;-)
@capJavert did you manage to resolve this?
@eclazi nope, I created my own protocol over thin UDP/TCP implementation. Using it for my app for quite some time.
I'm running into this issue too: Devices announcing themselves on the network whilst the bonjour browser is running are picked up, but go undetected otherwise.
I did some digging in Wireshark to see if the expected traffic was being sent, and found none when monitoring the expected network interface (Ethernet). However, when monitoring a different interface (eg, vEthernet for WSL, or "Loopback Pseudo-Interface"), I can see the MDNS queries going out.
It seems the selection of the correct interface, or the broadcasting to multiple interfaces isn't working as expected. In multicast-dns
I see the same behaviour (perhaps Node-related?), but there is an ability to force the interface, which makes things work more predictably. My minimum example code for testing here:
import { Bonjour } from 'bonjour-service';
import os from 'os';
var networkInterfaces = os.networkInterfaces();
console.log(networkInterfaces);
const bonjourInstance = new Bonjour({});
console.log("Starting network discovery");
let browser = bonjourInstance.find({ type: 'minismu', protocol: 'tcp' });
browser.on('up', service => {
console.log('Device up:', service);
});
browser.on('down', service => {
console.log('Device down:', service);
});
browser.on('error', err => {
console.error('Error occurred:', err);
});
browser.start();
I have the simple setup from the README.
Service.js:
Client.js:
When I publish and search services on the same computer (i am on macOS 12.1) they are discovered. But when I run the above code on two different machines eg. One computer is running
Service.js
and another one is runningClient.js
the find callback never triggers and no services are found.I can confirm that my HTTP server is visible if I manually input the computer address and go for example to the
GET /api
endpoint on another computer so they definitely see each other.Any tips on debugging this?