python-zeroconf icon indicating copy to clipboard operation
python-zeroconf copied to clipboard

Using sub type, avahi-browse does not show filtered on type. Is sub type implementation correct?

Open khan-git opened this issue 5 years ago • 1 comments
trafficstars

Using avahi-browseon a Ubuntu 18.04 I want to check that my service publishing works. With avahi-browse -ar I expect to see all services. With avahi-browse -r _zmq._tcp I expect to see only services of type _zmq._tcp including those with a sub type.

To test this I do avahi-publish-service --subtype=_foo._sub._zmq._tcp foo _zmq._tcp 9099 and the above commands show as expected.

I then use the following code to publish a service with sub type with python 3.7 and zeroconf 0.28.4:

from zeroconf import IPVersion, Zeroconf, ServiceInfo
import socket

if __name__ == "__main__":

    zeroconf = Zeroconf(ip_version=IPVersion.All)
    service_info = ServiceInfo(f"_bar._sub._zmq._tcp.local.",
                               f"bar._zmq._tcp.local.",
                               port=int(9090),
                               server=f"{socket.gethostname()}.local."
                               )

    zeroconf.register_service(service_info, allow_name_change=True)
    try:
        input("Press enter to exit...\n\n")
    finally:
        zeroconf.unregister_all_services()
        zeroconf.close()

avahi-browse -arwill show the service.. avahi-browse -r _zmq._tcp will not.

There don't seem to be many people using sub type and the documentation is rather short. Did I do something wrong in my code?

khan-git avatar Sep 14 '20 08:09 khan-git

Is there anyone else using subtype at all?

khan-git avatar Sep 16 '20 16:09 khan-git