Bug 26644

Summary: Butterfly drops incoming messages after conversation timeout
Product: Telepathy Reporter: William Grant <wgrant>
Component: butterflyAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium    
Version: git master   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description William Grant 2010-02-18 19:46:44 UTC
If a conversation is left idle for a minute or two, the server will time it out. If the remote end sends a message, a new conversation will be established. papyon sees the reestablishment and subsequent messages, but any messages after the reestablishment never get forwarded through to Empathy. If the conversation is instead reestablished from the local end, messages can travel in both directions without a problem.

To reproduce on one machine:
 1) Connect to one MSN account with Pidgin.
 2) Connect to another MSN account with Empathy.
 3) Start a conversation from Pidgin.
 4) Have a conversation.
 5) Say nothing for a minute or two until the switchboard disconnect.
 6) Send a message from Pidgin.
 7) Notice that Empathy has not seen the message.

I've seen this for a while now, but most recently on Ubuntu Lucid with telepathy-butterfly 0.5.4, telepathy-python 0.15.15 and papyon 0.4.4. I can also reproduce with git head of all three.

I had a dig through the code, and it appears that on_invite_conversation calls channel_for_props, which never actually attaches the conversation to an existing channel. It will pass it through to the channel's __init__ if creating a new one, but does nothing if it finds one existing. So the papyon conversation ends up with no butterfly event handler, so the messages get handled by nothing.

Applying the following patch makes things work again, but it's almost certainly the wrong solution.

=== modified file 'butterfly/connection.py'
--- butterfly/connection.py	2010-01-19 16:21:47 +0000
+++ butterfly/connection.py	2010-02-19 03:39:00 +0000
@@ -304,6 +304,9 @@
             handle, False, initiator_handle=handle)
         channel = self._channel_manager.channel_for_props(props,
             signal=True, conversation=conversation)
+        if channel._conversation is not conversation:
+            channel._conversation = conversation
+            papyon.event.ConversationEventInterface.__init__(channel, conversation)
 
     # papyon.event.InviteEventInterface
     def on_invite_conference(self, call):
Comment 1 Olivier Le Thanh Duong 2010-02-25 09:19:28 UTC
Thanks a lot for the report and detailed analysis, I managed to reproduce the bug easily thanks to your instructions and extended your patch to make it more complete. 

http://git.collabora.co.uk/?p=user/olethanh/telepathy-butterfly.git;a=shortlog;h=refs/heads/fix_attach_conversation
Comment 2 Jonny Lamb 2010-02-25 09:29:24 UTC
(In reply to comment #1)
> http://git.collabora.co.uk/?p=user/olethanh/telepathy-butterfly.git;a=shortlog;h=refs/heads/fix_attach_conversation

+        self._conversation= conversation
+        papyon.event.ConversationEventInterface.__init__(self, self._conversation)
+
+

Add a space before *and* after the equals sign, and remove the extra newline, and get mergin'.
Comment 3 Olivier Le Thanh Duong 2010-02-26 07:09:41 UTC
Corrected and merged thanks

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.