Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
KO #1
Member since Aug 2008 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Confused by PresenceType.Subscribed
Hi:

I'm completely confused by the subscribed presence type.  The MiniClient doesn't handle the subscribed type, and the behavior I'm seeing is contradictory to RFC 3921, which says:

A request to subscribe to another entity's presence is made by sending a presence stanza of type "subscribe".  When a client receives a subscription request from another entity, it MUST either approve the request by sending a presence stanza of type "subscribed" or refuse the request by sending a presence stanza of type "unsubscribed".

My client logs into the GMail server as KO@gmail.com (all names changed to protect the innocent).   As you can see from the output below, the only contacts in my roster are AAAAA@ihrisko.org and BBBBB@gmail.com.

If, using Psi, I log in using another jid, CCCCC@gmail.com, and then Add A Contact for KO@gmail.com, KO@gamil.com does NOT receive a "subscribe" presence entity - however, it DOES receive a "subscribed" stanza, followed by an immediate "available" presence from CCCCC@gmail.com.  I never even get a chance to approve or refuse the request.  KO@gmail.com is immediately added to CCCCC@gmail's roster, and CCCCC can immediately see KO@gmail's presence.

I turned on Psi's trace output, and I see a "subscribe" stanza going from Psi to the gmail server, but I never get it on the KO@gmail.com side.  I only get the "subscribed" stanza.

First, why is this happening?

Second, in my client, I am trying to automatically establish a "both" relationship with certain users when they add me as a contact.  Do I need to be using the same logic in my OnPresence handler for both "subscribe" and "subscribed" stanzas?

Here is the output:

IPV4
.
. login stuff removed
.
send: <iq id="agsXMPP_3" type="get"><query xmlns="jabber:iq:roster" /></iq>
recv: <iq xmlns="jabber:client" to="KO@gmail.com/AttnIMSvc5F81DD8A" type="result" id="agsXMPP_3"><query xmlns="jabber:iq:roster">
<item jid="AAAAA@ihrisko.org" subscription="both" /><item jid="BBBBB@gmail.com" subscription="both" /></query></iq>
send: <presence><show>chat</show><status /><priority>5</priority></presence>
recv: <presence xmlns="jabber:client" from="KO@gmail.com/KODEVO423EA36E7" to="KO@gmail.com/AttnIMSvc5F81DD8A">
<priority>5</priority>
<c xmlns="http://jabber.org/protocol/caps" ext="cs ep-notify html" ver="0.11-dev-rev8" node="http://psi-im.org/caps" />
<x xmlns="vcard-temp:x:update"><photo>5d85e1dbd46641c1a68589f001f35d1e1d7b12c3</photo></x></presence>
recv: <presence xmlns="jabber:client" from="CCCCC@gmail.com" to="KO@gmail.com" type="subscribed" />              <---------------------
recv: <presence xmlns="jabber:client" from="CCCCC@gmail.com/KODEVO4A737AB0E" to="KO@gmail.com">
<priority>5</priority>
<c xmlns="http://jabber.org/protocol/caps" ext="cs ep-notify html" ver="0.11-dev-rev8" node="http://psi-im.org/caps" />
<x xmlns="vcard-temp:x:update"><photo /></x></presence>
recv: <presence xmlns="jabber:client" from="CCCCC@gmail.com/KODEVO4A737AB0E" to="KO@gmail.com">
<priority>5</priority>
<c xmlns="http://jabber.org/protocol/caps" ext="cs ep-notify html" ver="0.11-dev-rev8" node="http://psi-im.org/caps" />
<x xmlns="vcard-temp:x:update"><photo /></x></presence>

Thank you!

KO
Avatar
Jabberer #2
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
look at frmSubcribe in the MiniClient. I think this is the code what you are looing for.

What most clients automatically do but MiniClient does not is check in the subscription approve logic:
If the contact I approve is not in my roster then add it automatically and send also a subscription request to this contact.
Maybe this is what you are missig here.
Software Developer
AG-Software
Avatar
KO #3
Member since Aug 2008 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Sorry, I'm Missing Something
Thank you Jabberer, but I don't see the code you are talking about.  In the MiniClient, frmSubscribe is only invoked when you get a "subscribe" presence.  My problem is that I never GET the "subscribe" presence.  I only get the "subscribed" presence, with a "d".  I think I understand how to handle a "subscribe", I just don't get one from the gmail server.  The relevant MiniClient code is empty I'm afraid:

            else if(pres.Type == PresenceType.subscribed)
            {

            }

If you look at the presence packets in the data I posted, you can see the "subscribed" (with a "d") packet come in from a user that is not in my roster.  From my limited understanding of the protocol, I didn't think that could happen.  I thought the "subscribed" presence could only follow a "subscribe".
Avatar
Jabberer #4
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
you have to do nothing when you get a subscribed.
The subscribed means that a contact (from jid) accepted your subscription request. There is no action required in the client.

You can show a message and tell the user that contact XX accpeted your subscription request. We did not add it because we think this messages are annoying and not neccesary. There is no XMPP action required.
Software Developer
AG-Software
Avatar
KO #5
Member since Aug 2008 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Let's Start Over
Jabberer,

The problem is that I haven't MADE a subscription request.  Here is the sequence of events:

1) ko@gmail.com has no presence relationship with ccccc@gmail.com, and ccccc.gmail.com has no presence relationship with ko@gmail.com (that I can see).

2) Using Psi, ccccc.gmail.com clicks on "Add A Contact", types in KO@gmail.com and hits OK.

3) KO@gmail.com immediately gets a "subscribed" presence packet from gmail.com.  No "subscribe" packet shows up (see the output I posted.)

4) KO@gmail.com immediately shows up in ccccc@gmail.com's roster, and shows as "Available".

I have "unsubscribed" ko@gmail.com from ccccc and ccccc from ko@gmail.com several times testing this.  Maybe there is just some lingering presence garbage on the server that doesn't show up in either roster.  Maybe I'll try using some new, clean accounts.

Thanks, KO
Avatar
Jabberer #6
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
ya, something is strange here.

To me it looks like the Google server automatically authorizes your requests. Maybe its caching that you accepted the request before.
Can you please try:
  • with another XMPP server not runing at Google
  • some other accounts on the Google server which had no subscription before.

The Google XMPP server behaves different in some scenarios and does not always follow the RFC's. So when possible please try another XMPP server or install your own local XMPP server for your development. There are many free compliant XMPP servers available.
Software Developer
AG-Software
Avatar
KO #7
Member since Aug 2008 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Will do
Thanks Jabberer.  Being new to XMPP, I'm quick to assume that I am doing something wrong.  In this case, it really looks like Google is doing something unexpected.  I'll take your advice and get my own server so I have complete control.
Avatar
Alex #8
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
there are also many public free servers on the internet like jabber.org.

Here is a very small list of free servers:
http://www.jabber.org/web/Services

Regards,
Alex
Avatar
KO #9
Member since Aug 2008 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: That was it
Just in case anyone else comes across this behavior, I thought I would leave a final status.  My client code works perfectly with an ejabberd server - everything works exactly as you already expected.  Google Talk must cache something on the server that I couldn't see.
Avatar
Alex #10
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
KO, thanks for the confirmation.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS