frawau / aiozeroconf

An asyncio/pure python implementation of multicast DNS service discovery
GNU Lesser General Public License v2.1
25 stars 6 forks source link

How to advertise a sub-type #11

Open cmcqueen opened 5 years ago

cmcqueen commented 5 years ago

Reading through the code, it looks as though a sub-type (such as _craig._sub._http._tcp.local.) could be advertised as follows:

info = ServiceInfo("_craig._sub._http._tcp.local.",
                   "Craig._http._tcp.local.",
                   address=socket.inet_aton("192.168.1.100"),
                   port=80,
                   properties=desc, server="craig.local.")

It seems to nearly work, but it doesn't necessarily show up when another PC browses the main type (_http._tcp.local. in this case).

Also, how would it be possible to advertise multiple sub-types?

frawau commented 5 years ago

Hi,

Thanks for the message.

To tell you the truth, I don't remember trying to advertise a service... but I think it should work...

I am a bit confused by you message...

Your code is just showing that you create a service, not that you start a task with "service_register", so do you?

When you say " it doesn't necessarily show up when another PC", do you mean it "sometimes does", "it always does" or it "never does".... also it the listening PC using aiozeroconf or something else?

Cheers

cmcqueen commented 5 years ago

Your code is just showing that you create a service, not that you start a task with "service_register", so do you?

I just quoted the one essential line, which I was testing in the context of the registration.py example. The essential point is that the first parameter can be "_craig._sub._http._tcp.local", which advertises that sub-type. But, it doesn't also advertise the type "_http._tcp.local".

When you say " it doesn't necessarily show up when another PC", do you mean it "sometimes does", "it always does" or it "never does".... also it the listening PC using aiozeroconf or something else?

If I do a query in Windows using dns-sd -B _http._tcp, then it doesn't appear. But querying the sub-type using dns-sd -B _craig._http._tcp does find it. With avahi on Linux, using avahi-browse _http._tcp it also doesn't appear. Running avahi-browse _craig._sub._http._tcp, it does. The only thing that does kind-of work is, running the avahi-discover GUI, it shows up in the tree under Web Site.

So, a service should be able to be advertised with one type such as _http._tcp, as well as one or more sub-types.