1

As of Catalina I've quit Apache and switched to Tornado. Apache was easy to configure http Zeroconf broadcast port 80 on the LAN. What I am looking for is an Avahi type solution where I can configure services independent of the originating process.

How would I do it when using another server software like Tornado?

4
  • Apache has deprecated that service, but they do offer clues.... activemq.apache.org/zeroconf.html. that said, wouldn’t this question be better addressed on Pro Webmasters?
    – Allan
    Commented Aug 10, 2020 at 6:11
  • Bonjour and mdns are industry standards, a bit code based, but since it’s so ubiquitious in the various Apple OS that ship and core to the design intent where Apple focuses on user-experience, I’d want to see this kept here in some version. Few minutes of checking the googles yield excellently documented, python code to do just this.. especially since OP is running this all on Catalina, it’s squarely on topic as I see it.
    – bmike
    Commented Aug 10, 2020 at 6:35
  • I’m not saying it's off topic per se @bmike, just from a pragmatic standpoint, the answer is likely to get better exposure due to the audience .
    – Allan
    Commented Aug 10, 2020 at 6:40
  • With a lot of python, @Allan - you’re correct SO or other sites will have very germane expertise for the overall problem space.
    – bmike
    Commented Aug 10, 2020 at 6:42

1 Answer 1

1

You’ve got several choices here of existing libraries of open source code with quite good documentation. In essence, your server needs to know an IP address and then drop the service advertisement.

Here’s JavaScript code to add http listener advertisement from one node.js based implementation:

var browser = mdns.createBrowser(mdns.tcp('http'), {resolverSequence: sequence});

Since you mentioned Tornado - you might be interested in a python zeroconf library that does the same and also lists Avahi compatibility in addition to Zeroconf.

The example code to advertise a fake HTTP server is a bit longer than the node call above, but the code is all open source. Making a real HTTPS server isn’t much more code, so you might be close to your solution here.

The core is what you’d expect - list the details and then advertise...

info = ServiceInfo(
    "_http._tcp.local.",
    "Paul's Test Web Site._http._tcp.local.",
    addresses=[socket.inet_aton("127.0.0.1")],
    port=80,
    properties=desc,
    server="ash-2.local.",
)

zeroconf = Zeroconf(ip_version=ip_version)
print("Registration of a service, press Ctrl-C to exit...")
zeroconf.register_service(info)
2
  • That works for me, thank you! Although I don't understand why I can't simply add the http service to the existing OSX Bonjour broadcaster. Commented Aug 10, 2020 at 15:20
  • 1
    The process that opens the port is responsively for advertising. The existing service is apachectl which you are moving away from @Gnarlodious
    – bmike
    Commented Aug 10, 2020 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .