Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

It does not seem like publish() actually publishes publicly properly #46

Open
StefanWallin opened this issue Jan 5, 2024 · 5 comments

Comments

@StefanWallin
Copy link

StefanWallin commented Jan 5, 2024

This might be duplicate of #9 or #13, if that's the case I'm sorry!

馃 馃嵒 Thanks in advance for great work with open sourcing this. 馃帀

I'm trying this on:

  • Mac OS Sonoma 14.2.1 on a M1 Apple Silicon
  • npx ts-node -v: v10.9.2
  • node -v: `v18.13.0
  • Discovery.app 2.1.0 (6)

Description

I'm trying to implement the react-native-zeroconf library in my react native app and serve from my server with your bonjour-service, but It does not seem that the announce from this library is reaching the network properly.

If I use the Discovery App I can see services such as Airplay and others, but not whatever I announce from this library.

If I try to scan for airplay over tcp with react-native-zeroconf I get matches from within my iOS simulator I will see my apple TV which is only connected by bluetooth even.

My setup

index.ts

import Bonjour from "bonjour-service";

const init = async () => {
  const instance = new Bonjour();
  console.log("Publishing bonjour service");
  const a = instance.publish({
    name: "TestApp Desktop Server",
    type: "testapp",
    protocol: "tcp",
    port: 3000,
  });

  while (true) {
    // keep the process alive
    await new Promise((resolve) => setTimeout(resolve, 4000));
    console.log("instance", a);
    await new Promise((resolve) => setTimeout(resolve, 2000));
    console.log("Waiting...");
  }
};

init();

It will output something like this:

instance Service {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  probe: true,
  published: true,
  activated: true,
  destroyed: false,
  txtService: DnsTxt { binary: undefined },
  name: 'TestApp Desktop Server',
  protocol: 'tcp',
  type: '_testapp._tcp',
  port: 3000,
  host: 'carambola-124.local',
  fqdn: 'TestApp Desktop Server._testapp._tcp.local',
  txt: undefined,
  subtypes: undefined,
  disableIPv6: false,
  start: [Function: bound start],
  stop: [Function: bound stop],
  [Symbol(kCapture)]: false
}
Waiting...

If I use bounjour-service as client it works, but not ideal for a react native environment, and it's weird that other applications cannot see the announcement either.
Screenshot 2024-01-05 at 19 24 39

@StefanWallin
Copy link
Author

In contrast, mdns works directly out of the box for me:

mdns.ts

const mdns = require("mdns");

const init = async () => {
  console.log("Publishing bonjour service");
  const ad = mdns.createAdvertisement(mdns.tcp("testapp"), 3000);
  ad.start();

  while (true) {
    // keep the process alive
    await new Promise((resolve) => setTimeout(resolve, 4000));
    console.log("instance", ad);
    await new Promise((resolve) => setTimeout(resolve, 2000));
    console.log("Waiting...");
  }
};

init();
Screenshot 2024-01-05 at 19 38 59

@mdidon
Copy link
Member

mdidon commented Jan 5, 2024

@StefanWallin Thanks for the heads up. It maybe related to the issues mentioned but I'll have to dig further to see if I can replicate.
I've not personally tested with React Native but I know iOS directly does work. You may however need to set NSBonjourServices in the Info.plist file to allow for scanning.

@mdidon
Copy link
Member

mdidon commented Jan 5, 2024

@StefanWallin Also, which version of bonjour-service are you using?

@StefanWallin
Copy link
Author

your client detects both, but mdns-client cannot detect from this library.

@StefanWallin
Copy link
Author

StefanWallin commented Jan 5, 2024

I realized that one thing that might be interesting to know is that I'm currently without a stable wifi since I'm in my mountain cabin and not at home. So my current network setup is my macbook relying on being wifi-connected to an iPhone with Internet Sharing turned on and using that as a hotspot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants