Bug 51501 - Avahi doesn't notify us when a contact drops off the network.
Summary: Avahi doesn't notify us when a contact drops off the network.
Status: RESOLVED MOVED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: salut (show other bugs)
Version: 0.8
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-27 23:30 UTC by Ajay Garg
Modified: 2019-12-03 20:16 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Ajay Garg 2012-06-27 23:30:50 UTC
Steps to Reproduce:
==========================

When a contact disconnects (from the telepathy network), the callback
function, specified for the signal

http://telepathy.freedesktop.org/spec/Connection_Interface_Contact_List.html#Signal:ContactsChangedWithID

is NOT hit.





  
Actual results:
===================
The callback function, specified for the signal

http://telepathy.freedesktop.org/spec/Connection_Interface_Contact_List.html#Signal:ContactsChangedWithID

is NOT hit.






Expected results:
===================
The callback function, specified for the signal

http://telepathy.freedesktop.org/spec/Connection_Interface_Contact_List.html#Signal:ContactsChangedWithID

SHOULD BE hit.






Additional info:
===================

a)
One thing I notice is that both - 'ContactChanged' and 'ContactsChangedWithID' - callbacks are hit when the buddy comes online, but are NOT hit when the same buddy goes offline (by disconnecting from the telepathy-salut wifi network).

So, I guess I am using the code properly at least, in case of both 'ContactsChanged' and 'ContactsChangedWithID'.




b)
Following are the telepathy-packages, that were installed on F17 where this bug occurred ::

telepathy-haze-0.6.0-1.fc17.i686
telepathy-idle-0.1.11-2.fc17.i686
telepathy-logger-0.4.0-2.fc17.i686
python-telepathy-0.15.19-4.fc17.noarch
telepathy-farstream-0.4.0-2.fc17.i686
telepathy-filesystem-0.0.2-3.fc17.noarch
telepathy-mission-control-5.12.0-1.fc17.i686
telepathy-glib-0.18.0-1.fc17.i686
telepathy-salut-0.8.0-1.fc17.i686
telepathy-gabble-0.16.0-1.fc17.i686






Mailinglist discussions at ::
====================================

http://www.mail-archive.com/telepathy@lists.freedesktop.org/msg05699.html
Comment 1 Will Thompson 2012-07-04 00:56:27 UTC
I've just tested this locally, just monitoring signals emitted by telepathy-salut using `dbus-monitor sender=org.freedesktop.Telepathy.ConnectionManager.salut`, and the right signals seem to be emitted when a Salut contact disconnects. (With the caveat that, because I only have one machine on me, the contact is a copy of Pidgin running on the same machine—but it should be equivalent as far as Salut is concerned.)

I'm using Salut 0.8.0 (as you are) and telepathy-glib 0.18.1 (which supposedly has no changes related to this compared to 0.18.0). Could you post your Python code exhibiting the issue?

Here's the dbus-monitor log from doing the following:

• Sign in with Empathy and Pidgin;
• Run `dbus-monitor sender=org.freedesktop.Telepathy.ConnectionManager.salut`;
• Quit Pidgin.

You can see that a presence update to offline and the ContactsChanged signals are all emitted as expected.

signal sender=:1.2265 -> dest=(null destination) serial=178 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt; interface=org.freedesktop.Telepathy.Connection.Interface.Presence; member=PresenceUpdate
   array [
      dict entry(
         uint32 2
         struct {
            uint32 0
            array [
               dict entry(
                  string "offline"
                  array [
                  ]
               )
            ]
         }
      )
   ]
signal sender=:1.2265 -> dest=(null destination) serial=179 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt; interface=org.freedesktop.Telepathy.Connection.Interface.SimplePresence; member=PresencesChanged
   array [
      dict entry(
         uint32 2
         struct {
            uint32 1
            string "offline"
            string ""
         }
      )
   ]
signal sender=:1.2265 -> dest=(null destination) serial=180 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt/ContactList/subscribe; interface=org.freedesktop.Telepathy.Channel.Interface.Group; member=MembersChanged
   string ""
   array [
   ]
   array [
      uint32 2
   ]
   array [
   ]
   array [
   ]
   uint32 0
   uint32 0
signal sender=:1.2265 -> dest=(null destination) serial=181 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt/ContactList/subscribe; interface=org.freedesktop.Telepathy.Channel.Interface.Group; member=MembersChangedDetailed
   array [
   ]
   array [
      uint32 2
   ]
   array [
   ]
   array [
   ]
   array [
      dict entry(
         string "contact-ids"
         variant             array [
            ]
      )
   ]
signal sender=:1.2265 -> dest=(null destination) serial=182 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt/ContactList/publish; interface=org.freedesktop.Telepathy.Channel.Interface.Group; member=MembersChanged
   string ""
   array [
   ]
   array [
      uint32 2
   ]
   array [
   ]
   array [
   ]
   uint32 0
   uint32 0
signal sender=:1.2265 -> dest=(null destination) serial=183 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt/ContactList/publish; interface=org.freedesktop.Telepathy.Channel.Interface.Group; member=MembersChangedDetailed
   array [
   ]
   array [
      uint32 2
   ]
   array [
   ]
   array [
   ]
   array [
      dict entry(
         string "contact-ids"
         variant             array [
            ]
      )
   ]
signal sender=:1.2265 -> dest=(null destination) serial=184 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt; interface=org.freedesktop.Telepathy.Connection.Interface.ContactList; member=ContactsChangedWithID
   array [
   ]
   array [
   ]
   array [
      dict entry(
         uint32 2
         string "pidjt@queeg"
      )
   ]
signal sender=:1.2265 -> dest=(null destination) serial=185 path=/org/freedesktop/Telepathy/Connection/salut/local_xmpp/wjt; interface=org.freedesktop.Telepathy.Connection.Interface.ContactList; member=ContactsChanged
   array [
   ]
   array [
      uint32 2
   ]
Comment 2 Ajay Garg 2012-07-04 01:10:17 UTC
Thanks Will.
That works on my side as well.

However, the problem  comes up when there are two different physical machines, connected only by a (telepathy-salut) wifi network.

I don't think it is necessary, but when I say that the buddy gets disconnected from the (telepathy-salut) network, I mean to say that there is no link between the (earlier) buddy-machine and the wifi AP. 

Please let me know if any other information is required.

Thanks Will for the reply. I am grateful.
Comment 3 Will Thompson 2012-07-04 02:32:32 UTC
(In reply to comment #2)
> I don't think it is necessary, but when I say that the buddy gets disconnected
> from the (telepathy-salut) network, I mean to say that there is no link between
> the (earlier) buddy-machine and the wifi AP.

Ah, so this is what I was missing. Sure enough, there doesn't seem to be any immediate notification. Avahi doesn't give Salut any indication. I don't know how Avahi is supposed to deal with this—I would personally expect the contacts to disappear after a while, but I don't know what that timeout should be, or whether Avahi does this.
Comment 4 Simon McVittie 2012-07-04 03:19:06 UTC
(In reply to comment #3)
> Sure enough, there doesn't seem to be any
> immediate notification. Avahi doesn't give Salut any indication. I don't know
> how Avahi is supposed to deal with this—I would personally expect the contacts
> to disappear after a while

If the contact deliberately goes offline (e.g. Telepathy Disconnect() method or setting their IM status to Offline), you should see them disappear straight away, as Will did, because Avahi sends an mDNS "goodbye" packet. If they just disconnect from wifi, Avahi doesn't get a chance to do that - by the time it finds that connectivity has been lost, it's too late for it to send "goodbye", because it has already lost connectivity!

What ought to happen is that the contact is considered to be present until the TTL (time-to-live) of the mDNS record runs out; then you should see the contact disappear.

https://tools.ietf.org/html/draft-cheshire-dnsext-multicastdns-15#section-10 suggests that the time-to-live of the mDNS record is likely to be 120 seconds, although we might set it to something else in Salut.
Comment 5 Simon McVittie 2012-07-04 03:31:39 UTC
(In reply to comment #4)
> https://tools.ietf.org/html/draft-cheshire-dnsext-multicastdns-15#section-10
> suggests that the time-to-live of the mDNS record is likely to be 120 seconds,
> although we might set it to something else in Salut.

Salut doesn't change the TTL from the default. However, PTR records in Avahi seem to get a TTL of 75 minutes, by using AVAHI_DEFAULT_TTL instead of AVAHI_DEFAULT_TTL_HOST_NAME:

/** The default TTL for RRs which contain a host name of some kind. */
#define AVAHI_DEFAULT_TTL_HOST_NAME (120)

/** The default TTL for all other records. */
#define AVAHI_DEFAULT_TTL (75*60)

The Internet-Draft says:

   As a general rule, the recommended TTL value for Multicast DNS
   resource records with [...] a host name contained within the resource
   record's rdata (e.g. SRV, reverse mapping PTR record, etc.) SHOULD be
   120 seconds.

so this is probably an Avahi bug?
Comment 6 Ajay Garg 2012-07-04 05:52:25 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Sure enough, there doesn't seem to be any
> > immediate notification. Avahi doesn't give Salut any indication. I don't know
> > how Avahi is supposed to deal with this—I would personally expect the contacts
> > to disappear after a while
> 
> If the contact deliberately goes offline (e.g. Telepathy Disconnect() method or
> setting their IM status to Offline), you should see them disappear straight
> away, as Will did, because Avahi sends an mDNS "goodbye" packet. If they just
> disconnect from wifi, Avahi doesn't get a chance to do that - by the time it
> finds that connectivity has been lost, it's too late for it to send "goodbye",
> because it has already lost connectivity!

I had exactly the same intuition !!





> 
> What ought to happen is that the contact is considered to be present until the
> TTL (time-to-live) of the mDNS record runs out; then you should see the contact
> disappear.

Me too thought on similar lines. 

That's why, I had enquired that whether we do need the unstable, experimental http://telepathy.freedesktop.org/spec/Connection_Interface_Keepalive.html :)






> 
> https://tools.ietf.org/html/draft-cheshire-dnsext-multicastdns-15#section-10
> suggests that the time-to-live of the mDNS record is likely to be 120 seconds,
> although we might set it to something else in Salut.
Comment 7 Ajay Garg 2012-07-04 05:59:18 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > https://tools.ietf.org/html/draft-cheshire-dnsext-multicastdns-15#section-10
> > suggests that the time-to-live of the mDNS record is likely to be 120 seconds,
> > although we might set it to something else in Salut.
> 
> Salut doesn't change the TTL from the default. However, PTR records in Avahi
> seem to get a TTL of 75 minutes, by using AVAHI_DEFAULT_TTL instead of
> AVAHI_DEFAULT_TTL_HOST_NAME:
> 
> /** The default TTL for RRs which contain a host name of some kind. */
> #define AVAHI_DEFAULT_TTL_HOST_NAME (120)
> 
> /** The default TTL for all other records. */
> #define AVAHI_DEFAULT_TTL (75*60)
> 
> The Internet-Draft says:
> 
>    As a general rule, the recommended TTL value for Multicast DNS
>    resource records with [...] a host name contained within the resource
>    record's rdata (e.g. SRV, reverse mapping PTR record, etc.) SHOULD be
>    120 seconds.
> 
> so this is probably an Avahi bug?

Thanks a ton Simon for your technical analysis.

So, what would you suggest ::

a)
Should telepathy change the TTL to "AVAHI_DEFAULT_TTL_HOST_NAME" (if possible) for all  cases ?


b)
Should Avahi change the TTL to "AVAHI_DEFAULT_TTL_HOST_NAME" for all cases ?
If yes, what is the bugtracker/mailing-lists for Avahi?



c)
If either of a) or b) is followed, would it cause one of the exisiting telepathy signals' callbacks to be hit? (for http://telepathy.freedesktop.org/spec/Connection_Interface_Contact_List.html#Signal:ContactsChangedWithID ??)



d)
Any how, if this is a simple fix, please do let me know the approach to be followed. I will be too happy to come up with a patch :D :D


Thanks again Will and Simon for your time.



Regards,
Ajay
Comment 8 Ajay Garg 2012-07-05 03:24:42 UTC
Hi all.

Changing the default timeout values to a lesser value (20 seconds) did help.
So, now I am curious as to how these values could be customized on the fly, without rebuilding the RPMS again and again.

Posted the query at avahi mailing-lists at http://lists.freedesktop.org/archives/avahi/2012-July/002153.html


Will be grateful to hear back, in case some angel have a suggestion already :)


Thanks and Regards,
Ajay
Comment 9 Ajay Garg 2012-07-05 07:01:42 UTC
Just found about /etc/avahi/avahi-daemon.conf.
That would do it !!! (of course after patching avahi to read-in the two new values).
Comment 10 Ajay Garg 2012-07-09 12:22:05 UTC
Wrote the patch to make the TTL values configurable, found at
http://people.sugarlabs.org/ajay/root/freedesktop_bug_51501/common-patch-for-f14-and-f17/


The corresponding Fedora-14 and Fedora-17 rpms can be found at ::
http://people.sugarlabs.org/ajay/root/freedesktop_bug_51501/platforms/f14/RPMS/
http://people.sugarlabs.org/ajay/root/freedesktop_bug_51501/platforms/f17/RPMS/


I will be happy to receive some feedback :) :)
Comment 11 Ajay Garg 2012-07-10 08:17:03 UTC
This is what Avahi guys have to say ::

http://www.mail-archive.com/avahi@lists.freedesktop.org/msg01896.html
Comment 12 GitLab Migration User 2019-12-03 20:16:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/telepathy/telepathy-salut/issues/38.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.