Summary:ASTERISK-10287: Gtalk call fails unless restarts
Reporter:Yusuf Motiwala (yusufmotiwala)Labels:
Date Opened:2007-09-12 10:22:57Date Closed:2007-10-07 10:58:37
Versions:Frequency of
Environment:Attachments:( 0) branch-1.4-10707-1.diff
Description:Here is scenario - asterisk is running.

1. Asterisk using abc@gmail.com as its Gtalk ID
2. Someone (say xyz@gmail.com) has added abc@gmail.com as buddy
3. If I try to place a call to Gtalk/asterisk/xyz@gmail.com, it fails -> No gtalk capable clients to talk to.
4. If I restart the asterisk, call goes.
5. It is always a case with new buddy

Please let me know if more information required.
Comments:By: Yusuf Motiwala (yusufmotiwala) 2007-09-12 11:00:22

This problem is presence in SVN also.

Additionally, there is a Jabber message "Got presence packet from ***, someone not in our roster!!!!", even though buddy was added and both can see each other's presence

By: Yusuf Motiwala (yusufmotiwala) 2007-09-12 13:32:39

FYI. This might get fixed by adding buddy adding code after roster error message mntioned above in res_jabber.c. I just did it, recompiled and seems to have solved the problem though I am not sure of it side effects.

By: phsultan (phsultan) 2007-09-13 03:02:04

Can you post the corresponding sections of the gtalk.conf and jabber.conf files? A console ouput with debugging messages would help too.


By: Yusuf Motiwala (yusufmotiwala) 2007-09-13 07:04:03

======== Below is jabber.conf ============

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

[asterisk]                              ;;label
type=client                             ;;Client or Component connection
serverhost=talk.google.com              ;;Route to server for example,
                                       ;;      talk.google.com
username=something@gmail.com       ;;Username with optional roster.
secret=****                         ;;Password
port=5222                               ;;Port to use defaults to 5222
usetls=yes                              ;;Use tls or not
usesasl=yes                             ;;Use sasl or not
buddy=somebuddy@gmail.com          ;;Manual addition of buddy to list.
statusmessage="mystatus"            ;;Have custom status message for

=========== Below is gtalk.conf     ===========

context=google-in               ;;Context to dump call into
allowguest=yes                  ;;Allow calls from people not in
                               ;;list of peers

[guest]                 ;;special account for options on guest account

username=somebuddy@gmail.com       ;;username of the peer your
                               ;;calling or accepting calls from
connection=asterisk             ;;client or component in jabber.conf
                               ;;for the call to leave on.

By: Yusuf Motiwala (yusufmotiwala) 2007-09-13 07:06:01

=== Following are temporary changes I made to res_jabber.c:1251 ===

if (!buddy) {
               ast_log(LOG_NOTICE, "Got presence packet from %s, someone not in our roster!!!!\n", pak->from->partial);

                               buddy = ast_calloc(1, sizeof(*buddy));
                               if (!buddy) {
                                       ast_log(LOG_WARNING, "Out of memory\n");
                                       return 0;
                               ast_copy_string(buddy->name, pak->from->partial, sizeof(buddy->name));
                               ast_clear_flag(buddy, AST_FLAGS_ALL);
                               if(ast_test_flag(client, AJI_AUTOPRUNE)) {
                                       ast_set_flag(buddy, AJI_AUTOPRUNE);
                                       buddy->objflags |= ASTOBJ_FLAG_MARKED;
                               } else
                                       ast_set_flag(buddy, AJI_AUTOREGISTER);
                               if (buddy) {
                                       ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);

By: phsultan (phsultan) 2007-09-13 07:09:17

Please also try one of the following actions :
- add xyz@gmail.com as a buddy in your jabber.conf file ;
- connect as abc@gmail.com with a regular GoogleTalk client, check if you're allowed to view xyz's presence.

Basically, the idea is that the 'subscription' attribute in the presence stanzas must be set to the 'both' value.

By: Yusuf Motiwala (yusufmotiwala) 2007-09-13 07:11:42

yes, as I mentioned, both are able to see each others presence. I created so many acount to try all variations. Even Asterisk receives presence packet.

By: phsultan (phsultan) 2007-09-13 07:14:56

Can you post a console debug output from your Asterisk server?

By: phsultan (phsultan) 2007-09-20 05:55:58

Were you able to get a console debug output? I'd really like to see the kind of presence stanzas exchanged.

By: Yusuf Motiwala (yusufmotiwala) 2007-09-23 03:28:22

Sorry for the delay - I was travelling. here is logs


JABBER: asterisk INCOMING: <iq type="result" id="auth"/>

JABBER: asterisk INCOMING: <iq to="asterisk@gmail.com/asterisk1F9C271F" id="roster" type="result"><query xmlns="jabber:iq:roster"/></iq>

JABBER: asterisk OUTGOING: <presence type='subscribe' to='otheruser@gmail.com'><status>Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence


JABBER: asterisk INCOMING: <iq to="asterisk@gmail.com/asterisk1F9C271F" id="201865DF" type="set"><query xmlns="jabber:iq:roster"><item jid="otheruser@gmail.com" subscription="none" ask="subscribe"/></query></iq>

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

JABBER: asterisk OUTGOING: <presence type='subscribed' to='someuser@gmail.com' from='asterisk@gmail.com/asterisk1F9C271F'><status>Asterisk has approved subscription</status></presence>

JABBER: asterisk INCOMING: <iq to="asterisk@gmail.com/asterisk1F9C271F" id="2018662A" type="set"><query xmlns="jabber:iq:roster"><item jid="someuser@gmail.com" subscription="from" ask="subscribe"/></query></iq>

JABBER: asterisk INCOMING: <presence type="subscribed" from="someuser@gmail.com" to="asterisk@gmail.com"/>

JABBER: asterisk INCOMING: <iq to="asterisk@gmail.com/asterisk1F9C271F" id="20186631" type="set"><query xmlns="jabber:iq:roster"><item jid="someuser@gmail.com" subscription="both"/></query></iq>

JABBER: asterisk INCOMING: <presence from="someuser@gmail.com/Talk.v10422287d60" to="asterisk@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="20070923T08:32:41" xmlns="jabber:x:delay"/><x xmlns="vcard-temp:x:update"><photo></photo></x></presence>
[Sep 23 11:42:50] NOTICE[4546]: res_jabber.c:1252 aji_handle_presence: Got presence packet from someuser@gmail.com, someone not in our roster!!!!

By: phsultan (phsultan) 2007-09-23 11:55:16

I understand you prefer not to expose the real GoogleTalk IDs in your debug output and configuration files, but please keep them consistent along your notes.

Is 'someuser@gmail.com' used by your Asterisk server to connect to Google's XMPP server as well?

Please also provide a debug output for a failed call.


By: phsultan (phsultan) 2007-09-23 12:58:25

Another question : did you wait enough time after restarting Asterisk before trying to place your call? I'm asking because Google's server sometimes delays the roster upload to the clients (up to 30 seconds).

By: Yusuf Motiwala (yusufmotiwala) 2007-09-23 13:35:34

yes, also, if I restart asterisk it call goes immiditely to nothing wrong from google server end.

By: phsultan (phsultan) 2007-09-25 11:01:13

Please try the attached patch and give your feedback, thanks!

By: phsultan (phsultan) 2007-09-25 11:19:25

Also, I just committed a new CLI function to SVN trunk that you may find useful : "jabber show buddies". As the name suggests, it displays the buddy list. This was a suggestion from danmckeehan, thanks Daniel.

Being a new feature, this function won't be backported to the 1.4 branch.

By: phsultan (phsultan) 2007-10-02 08:08:56

Did you have any chance to test the provided patch?

By: Digium Subversion (svnbot) 2007-10-07 10:55:22

Repository: asterisk
Revision: 84902

U   branches/1.4/res/res_jabber.c

r84902 | phsultan | 2007-10-07 10:55:21 -0500 (Sun, 07 Oct 2007) | 5 lines

Presence packets from a client who's connected with our Jabber ID are
valid, therefore, those clients must be considered as buddies. The resource
string helps us make the distinction between clients.

Closes issue ASTERISK-10287, reported by yusufmotiwala.

By: Digium Subversion (svnbot) 2007-10-07 10:58:37

Repository: asterisk
Revision: 84918

_U  trunk/
U   trunk/res/res_jabber.c

r84918 | phsultan | 2007-10-07 10:58:36 -0500 (Sun, 07 Oct 2007) | 13 lines

Merged revisions 84902 via svnmerge from

r84902 | phsultan | 2007-10-07 18:15:39 +0200 (Sun, 07 Oct 2007) | 5 lines

Presence packets from a client who's connected with our Jabber ID are
valid, therefore, those clients must be considered as buddies. The resource
string helps us make the distinction between clients.

Closes issue ASTERISK-10287, reported by yusufmotiwala.