mjansson / mdns

Public domain mDNS/DNS-SD library in C
The Unlicense
459 stars 120 forks source link

Avahi.InvalidServiceTypeError: Invalid service type #83

Open edward-jw-yu opened 8 months ago

edward-jw-yu commented 8 months ago

Ubuntu2004, mdns 1.4.3 gcc -o mdns mdns.c ./mdns --service test_mdnsmw_service1._http._tcp.local. --port 10001 --hostname vbox2.local ./mdns --service test_mdnsmw_service1._dns-sd._tcp.local. --port 10001 --hostname vbox2.local ./mdns --service test._http._tcp.local. opening avahi-discover came out the following: Browsing domain 'local' on -1.-1 ... Browsing for services of type '' in domain 'test._http._tcp.local' on 2.1 ... ERROR:dbus.connection:Exception in handler for D-Bus signal: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 232, in maybe_handle_message self._handler(args, kwargs) File "/usr/bin/avahi-discover", line 182, in new_service_type b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER) File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 147, in call keywords) File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 653, in call_blocking message, timeout) DBusException: org.freedesktop.Avahi.InvalidServiceTypeError: Invalid service type Browsing for services of type '' in domain 'test._http._tcp.local' on 2.0 ... ERROR:dbus.connection:Exception in handler for D-Bus signal: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 232, in maybe_handle_message self._handler(args, kwargs) File "/usr/bin/avahi-discover", line 182, in new_service_type b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER) File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 147, in call keywords) File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 653, in call_blocking message, timeout) DBusException: org.freedesktop.Avahi.InvalidServiceTypeError: Invalid service type

mjansson commented 6 months ago

You should not handle DNS-SD like that - the library takes care of service discovery for you (which is handled by a _services._dns-sd._udp.local. query, see RFC in https://datatracker.ietf.org/doc/html/rfc6763)

Your service should probably not be test_mdnsmw_service1._http._tcp.local. - the _http._tcp.local. is the service name normally used for HTTP.

Also, hostname should be without the local suffix.