Summary:ASTERISK-11507: Gtalk call fails unless restarts (Maybe?! reopening issue 10707)
Reporter:Farid (ffadaie)Labels:
Date Opened:2008-02-25 14:43:39.000-0600Date Closed:2008-02-29 07:08:52.000-0600
Versions:Frequency of
Environment:Attachments:( 0) branch-1.4-12066-1.diff
( 1) trunk-12066-1.diff
Description:I am having the exact same issue as described in 10707. It seems that this is not completely resolved.
Here is a bit more details:
Asterisk is logged in as abc@gmail.com. I add abc@gmail.com as new buddy to my own gtalk account xyz@gmail.com. As soon as I add it, Asterisk receives presence information and supposedly add it to its buddy. However, when I try to call xyz@gmail.com from my Asterisk, the call does not go through!
Now, if I restart Asterisk, everything will be fine. In other words, whenever somebody adds Asterisk user (abc@gmail.com) as buddy, Asterisk must be restarted otherwise no calls can be made from Asterisk to that person.
Here is the console log when user xyz@gmail.com adds abc@gmail.com as buddy:

JABBER: asterisk INCOMING: <presence type="subscribe" to="abc@gmail.com" from="xyz@gmail.com"/>

JABBER: asterisk OUTGOING: <presence type='subscribed' to='xyz@gmail.com' from='abc@gmail.com/TalkFEC6CAF7'><status>Asterisk has approved subscription</status></presence>
JABBER: asterisk INCOMING: <iq to="abc@gmail.com/TalkFEC6CAF7" id="3F692613" type="set"><query xmlns="jabber:iq:roster"><item jid="xyz@gmail.com" subscription="from" ask="subscribe"/></query></iq>
JABBER: asterisk INCOMING: <presence type="subscribed" from="xyz@gmail.com" to="abc@gmail.com"/>
JABBER: asterisk INCOMING: <iq to="abc@gmail.com/TalkFEC6CAF7" id="3F69262A" type="set"><query xmlns="jabber:iq:roster"><item jid="xyz@gmail.com" subscription="both"/></query></iq>
JABBER: asterisk INCOMING: <presence from="xyz@gmail.com/Talk.v104D279DA8E" to="abc@gmail.com"><status/><priority>24</priority><c node="http://www.google.com/xmpp/client/caps" ver="" ext="share-v1 voice-v1" xmlns="http://jabber.org/protocol/caps"/><x stamp="20080225T20:27:28" xmlns="jabber:x:delay"/><x xmlns="vcard-temp:x:update"><photo/></x></presence>
[Feb 25 15:18:14] NOTICE[18292]: res_jabber.c:1179 aji_handle_presence: Got presence packet from xyz@gmail.com, someone not in our roster!!!!

When I try to call xyz@gmail.com at this moment I get the error that there is no gtalk capable client to talk to!
The error goes away as soon as I restart Asterisk!
Comments:By: Farid (ffadaie) 2008-02-25 14:49:40.000-0600


debug=yes                               ;;Turn on debugging by default.
autoprune=no                            ;;Auto remove users from buddy list.
autoregister=no/yes[makes no difference]                 ;;Auto register users from buddy list.

[asterisk]                              ;;label
type=client                             ;;Client or Component connection
serverhost=talk.google.com                      ;;Route to server for example,
username=abc@gmail.com/Talk       ;;Username with optional roster.
secret=XXXXX                              ;;Password
port=5222                               ;;Port to use defaults to 5222
usetls=yes                              ;;Use tls or not
usesasl=yes                             ;;Use sasl or not
statusmessage="YYY"          ;;Have custom status message for
timeout=100                             ;;Timeout on the message stack.


context=gg              ;;Context to dump call into
allowguest=yes                  ;;Allow calls from people not in
externip=[my_external_ip]                         ;;list of peers
[guest]                 ;;special account for options on guest account

By: phsultan (phsultan) 2008-02-26 11:48:12.000-0600

As a workaround, you can add xyz@gmail.com to your buddy list in the jabber.conf file.

I'll send a patch soon to clear that issue up.

Thanks for the report!

By: Farid (ffadaie) 2008-02-26 12:00:49.000-0600

In my case that is not really possible. It's very dynamic and Asterisk is working as a bridge. So, each time a user is added, we have to go and him/her to jabber.conf. It is extremely difficult to manage this in an environment with more than 10 Asterisk boxes. :) [specially without realtime]
We will be waiting for the patch.
Thanks for your quick response.

By: phsultan (phsultan) 2008-02-27 04:24:07.000-0600

Can you please try this one? Thanks!

By: Jason Parker (jparker) 2008-02-27 10:54:24.000-0600

Even if this patch doesn't get committed as-is, I'd really like to see that debug message switch at the bottom go away (the way you handled it in -1.diff is good).

By: Farid (ffadaie) 2008-02-28 02:42:53.000-0600

Where do I get this revision from? I have the one from the trunk which is so not this one!

By: phsultan (phsultan) 2008-02-28 03:10:01.000-0600

The patch applies to SVN 1.4 and 1.4.18 tarball. I'm attaching a patch for SVN trunk.

By: phsultan (phsultan) 2008-02-28 03:34:16.000-0600

Jason : ok, will do.

By: Farid (ffadaie) 2008-02-28 10:29:01.000-0600

I applied it to the tarball. Now when I add abc@gmail.com to the buddy list of xyz@gmail.com (for the first time), nothing actually happens. Now I get a strange behavior. I sometimes get

JABBER: asterisk INCOMING: <presence type="subscribe" to="abc@gmail.com" from="xyz@gmail.com"/>
JABBER: asterisk OUTGOING: <presence type='subscribed' to='xyz@gmail.com' from='abc@gmail.com/Talk52497ADB'><status>Asterisk has approved subscription</status></presence>

and sometimes I get nothing! In both cases xyz@gmail.com cannot see abc@gmail.com's presence. (even when I get "Asterisk has approved subscription"). For the sake of this test to be consistent each time, I create a new gtalk account and test it with that. So, each time this xyz@gmail.com is a different account (to prevent storing the previous state/roster).
I cannot make calls to xyz@gmail.com at all now. Even when I restart Asterisk! Basically I cannot add abc@gmail.com to the buddy list of anybody. It just makes calls to the people who were already in its roster before applying the patch.

Just to make it bold: The message "Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence" is never sent to xyz@gmail.com from Asterisk (even after restarting Asterisk).

By: phsultan (phsultan) 2008-02-28 11:09:05.000-0600

It looks like some messages from the XMPP GoogleTalk network don't reach your Asterisk client, is your network connection good?

You should receive the messages that modify your Asterisk's roster and remote buddy's type subscription, just as you would in the original bug report.

I observed that sometimes, retrieving the roster of an XMPP client can take some time, and XMPP messages to that client might be delayed. Make sure you've waited for some time between your Asterisk restarts.

I'm asking because I was able to reproduce your problem and fix it with the patch.

Also, which version of Asterisk are you actually using, SVN 1.4, SVN trunk or 1.4.18?

Thanks for your feedback!

By: phsultan (phsultan) 2008-02-28 11:13:19.000-0600

Ok, can you contact me directly so that I try to add your Asterisk server as one of my buddies?

philippe dot sultan at gmail dot com

By: Farid (ffadaie) 2008-02-28 11:20:15.000-0600

You are right. It's because of the timings. It works! I let it sit here for a while to see if there is any issues. I'll let you know.
Thanks for quick responses. OpenSource rocks :)

By: phsultan (phsultan) 2008-02-28 11:25:03.000-0600

Ok, glad to read that! Let me know if you still have problems so that I can commit the fix tomorrow.

By: Farid (ffadaie) 2008-02-29 02:31:11.000-0600

It's been working fine. We have not tested it under heavy load though. (It's not in production yet!)

By: Digium Subversion (svnbot) 2008-02-29 07:01:50.000-0600

Repository: asterisk
Revision: 105209

U   branches/1.4/res/res_jabber.c

r105209 | phsultan | 2008-02-29 07:01:38 -0600 (Fri, 29 Feb 2008) | 9 lines

Automatically create new buddy upon reception of a presence stanza of
type subscribed.

(closes issue ASTERISK-11507)
Reported by: ffadaie
     branch-1.4-12066-1.diff uploaded by phsultan (license 73)
     trunk-12066-1.diff uploaded by phsultan (license 73)
Tested by: ffadaie, phsultan


By: Digium Subversion (svnbot) 2008-02-29 07:08:52.000-0600

Repository: asterisk
Revision: 105210

U   trunk/res/res_jabber.c

r105210 | phsultan | 2008-02-29 07:08:49 -0600 (Fri, 29 Feb 2008) | 9 lines

Automatically create new buddy upon reception of a presence stanza of
type subscribed.

(closes issue ASTERISK-11507)
Reported by: ffadaie
     branch-1.4-12066-1.diff uploaded by phsultan (license 73)
     trunk-12066-1.diff uploaded by phsultan (license 73)
Tested by: ffadaie, phsultan