keepsimple1 / mdns-sd

Rust library for mDNS based Service Discovery
Apache License 2.0
96 stars 37 forks source link

SRV TTL triggers timeout event #176

Closed wfeii1980 closed 5 months ago

wfeii1980 commented 7 months ago

issue 54 Add ServiceEvent::ServiceInactive

keepsimple1 commented 7 months ago

Thanks for your PR! Could you please describe the problem at hand?

From the title, my understanding is that SRV TTL expired while PTR record was still valid because PTR has 75 mins TTL while SRV only has 2 mins TTL. Is that the problem?

If yes, I think the direct cause is that currently we checks only PTR record for refresh due. If we send out TYPE_SRV refresh query when SRV is due to refresh, will that solve your problem?

At the high level, I think if SRV TTL indeed expires (even with refresh), which means the server no longer exists for the service instance, we should generate ServiceRemoved as the service instance is no longer valid. It seems to me ServiceInactive is too similar to ServiceRemoved and would cause confusions.

wfeii1980 commented 7 months ago

Because I don't quite understand the difference between PTR and SRV timeout, I added a ServiceInactive.

keepsimple1 commented 7 months ago

Because I don't quite understand the difference between PTR and SRV timeout, I added a ServiceInactive.

Both PTR and SRV (and address records A / AAAA) are required to have a complete service instance. I think any of them timeout should generate the event ServiceRemoved. Do you need to know which of them caused the ServiceRemoved ? If yes, then we need to find a way to distinguish them.

keepsimple1 commented 7 months ago

I added a draft PR #180 to address the issues here. Let me know what you think. @wfeii1980 . Thanks.

keepsimple1 commented 6 months ago

I've updated the PR #180 to support your use case. Would you please help check if that PR can:

  1. refresh SRV when the responder is alive.
  2. trigger ServiceRemoved when the SRV expires and the responder no longer alive

Please let me know if any issues. Thanks! (and just to clarify, @wfeii1980 I will add you as co-author in #180 because it was inspired by yours)

keepsimple1 commented 6 months ago

@wfeii1980 please let me know what do you think about PR #180 ? Would it help your use case?

wfeii1980 commented 5 months ago

upgrade to 0.11.0 very good!

keepsimple1 commented 5 months ago

I've merged PR #180, which should have fixed this one. If you still have issues with SRV TTL triggers, please open a new issue, or re-open this one. Thanks!