Skip to content

Is ServiceResolved supposed to catch SRV and TXT advertisements? #433

@dorfsmay

Description

@dorfsmay

I'm running this simple code. It is printing Service Type advertisements (ServiceFound and ServiceRemoved) but not Service Instance advertisements (SRV, TXT). Is ServiceResolved supposed to do this?

In different windows I'm running:

  • cargo run to run this code
  • tshark -i vmbr0 -f "udp port 5353" -Y mdns - on the same laptop
  • avahi-publish -s blah _blah._tcp 4443
  • avahi-browse -r _ipp._tcp
  • tshark -i vmbr0 -f "udp port 5353" -Y mdns - on a different machine on the same network

When I run the service (publish -s blah), I can see it being added and removed. When I query _ipp, my printer answers and I see the SRV and TXT advertisement in tshark, on both my laptop and the other machine, but this code is not printing anything. I do not see any ServiceResolved printed, ever.

use mdns_sd::{ServiceDaemon, ServiceEvent};

fn main() -> anyhow::Result<()> {
    let worker = ServiceDaemon::new()?;
    let _accept_unscolicited = worker.accept_unsolicited(true);
    //let cloned_worker = worker.clone();

    let receiver = worker.browse("_services._dns-sd._udp.local.")?;

    while let Ok(event) = receiver.recv() {
        match event {
            ServiceEvent::ServiceFound(service_type, fullname) => {
                println!(
                    "Found service type/instance: {} / {}",
                    service_type, fullname
                );
                //let _service_instance_query = cloned_worker.browse(&service_type);
                //let _service_instance_query = worker.browse(&service_type);
            }   
            ServiceEvent::ServiceRemoved(service_type, fullname) => {
                println!("Service removed: {}/{}", service_type, fullname);
            }   
            ServiceEvent::ServiceResolved(resolved) => {
                println!("Resolved a new service: {}", resolved.fullname);
            }
            ServiceEvent::SearchStarted(_service) | ServiceEvent::SearchStopped(_service) => (), 
            other_event => {
                // ServiceEvent is non-exhaustive
                println!("Received other event: {:?}", &other_event);
            }   
        }   
    }   
    Ok(())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions