0

I'm trying to write some kind of service browser with Avahi. Discovering and resolving new services works just fine, however I'm facing a problem when I try to resolve service that was lost in ItemRemoved handler. "org.freedesktop.Avahi.TimeoutError: Timeout reached" error occures. I suppose I'm doing it wrong way, thus my question is:

How can i resolve IP address of lost service in ItemRemoved handler?

Buyuk
  • 1,094
  • 1
  • 8
  • 23

2 Answers2

0

If a service is removed, you won't be able to resolve it since the service no longer exists. It's records are no longer valid.

What you need to do is use the DNS-SD service name (e.g. My Print Service._http._tcp) as the key that you store and remove things from in your internal cache.

Ideally you would only resolve the service when you actually need to connect to it, this helps both in reducing network traffic and also ensuring the IP address up to date/valid when you go to use it. Once resolved if you store the IP along with the service name, then you have what you need it would seem.

Trent Lloyd
  • 1,832
  • 1
  • 15
  • 13
  • Thanks for answering me, can be useful in the future. Unfortunately I was unable to cache services' names since format of service's record had been forced upon me and I could store only IP and port number. – Buyuk Mar 18 '15 at 10:51
  • Why can you not keep an internal cache of the name to IP resolutions you previously performed? – Trent Lloyd Mar 18 '15 at 23:47
  • In case of the services list which I'm keeping, its a file which needs to be kept in a ; ; ... format. It must be persistently stored on the hard drive, thus I would have to store another file with IP- SERVICE_NAME resolutions as you suggested.This cant be, since I cannot create any temporary files. – Buyuk Mar 19 '15 at 10:03
0

I am experiencing the same TimeoutError problems with Avahi between client Linux Mint 18 and service provider Raspbian 9 (stretch), but my issues are intermittent, but seem to be often after a reboot of the Rasbian pc.

I have noticed that when the Avahi-Discover (sudo apt install avahi-discover on the client) shows the service but WITHOUT any data, then that is when I get the TimeoutError, so I simply repeat "service avahi-daemon restart" (on the avahi service provider) until I get data in the avahi-discover on the client.

This is not a solution, but it is a fix. And I need to get on with other work that uses the avahi service, not spend time resolving avahi issues. I have found very few solutions on the internet, but lots of unresolved examples. and this for me has been going on for weeks now, as has my investigations. I hope this fix helps and starts more discussions into resolving this annoying issue.

Phil Busby
  • 33
  • 5