Skip to content

Android 13 drops a service every 2 minutes: known answers with an impossible TTL suppress all answers #537

Closed

Description

@meliodaff

What happens: a Redmi Note 12 on Android 13 (MdnsDiscoveryManager from the connectivity module) browses _lara._tcp every ~2 s. Each query lists our PTR as a known answer with a TTL of about 390000 s, which grows by about 1 s per second. We send that PTR with TTL 4500, so a correct remaining TTL could never exceed 4500. Under RFC 6762 §7.1 (suppressed_by_answer: known TTL > half of ours) every answer is suppressed, so the phone never receives the 120 s SRV and A records again. When they expire, Android logs:

[MdnsDiscoveryManager._lara._tcp.local-115/36] TTL expired. onServiceRemoved: Name: <instance>, ...
[NsdService] MdnsDiscoveryManager event code=SERVICE_LOST

That happened every 2 minutes in a 6-minute capture (4 times). The service came back only after the phone's next query without known answers, 0.1 s to 40 s later. A responder that ignores known answers (we compared with libmdns) has no drops with the same phone.

To reproduce: register any service with 0.21.6 on the LAN, browse it from an Android 13 device through NsdManager (discoverServices and periodic resolveService), and watch adb shell dumpsys servicediscovery. A capture on the responder shows the PTR known answers with TTL ~390000.

Possible fix: treat a known answer whose TTL is above the record's own TTL as invalid, so it does not suppress:

fn suppressed_by_answer(&self, other: &dyn DnsRecordExt) -> bool {
    let ttl = self.get_record().ttl;
    let other_ttl = other.get_record().ttl;
    self.matches(other) && other_ttl > ttl / 2 && other_ttl <= ttl
}

A correct querier never sends such a TTL, so this can only add answers, never remove one. With it, the same phone held the service for 6 minutes with no TTL expired, and all crate tests pass, including test_known_answer_suppression. I can send this as a PR with a unit test (test_known_answer_with_impossible_ttl_does_not_suppress).

Activity

  1. keepsimple1 commented on Nov 2, 2026

    @keepsimple1
    Owner

    Thanks for opening this issue! It's an interesting case. Your proposed fix makes sense. Please go ahead open a PR.

    There is a rare case when a querier had the record cached from an earlier registration that did use a larger custom TTL. But I think it's OK trade-off: there will just be one extra answer (i.e. not suppressing) that is harmless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions