Вопрос

I'm trying to send a subscribe stanza from a (a@gmail.com) to b(b@gmail.com), but the Google Talk XMPP server isn't forwarding the stanza (i.e. b never receives it).

If I log in to Gmail with a@gmail.com and invite b@gmail.com, b@gmail.com does receive the IQ stanza and it looks like this:

<presence xmlns='jabber:client' from='a@gmail.com' type='subscribe' to='b@gmail.com'><sub:invitation xmlns:sub='google:subscribe'><sub:body/></sub:invitation></presence>  

[Note that from and to are both just the usernames not the full JID specifying a specific chat resource like a@gmail.com/ABC145D]

If I try to construct a presence stanza like the one b receives when doing it through gmail, I get a 'bad-request' error from the GTalk XMPP server saying:

If set, the 'from' attribute must be set to the user's full JID.    

However, if I try a) specifying the full "from" JID, b) leaving the "from" off the stanza entirely, or c) specifying the full JID for "from" and "to", none of them work. GTalk XMPP server does not transmit the presence subscription request from a@gmail.com to b@gmail.com

Это было полезно?

Решение

I got it to work with a stanza of the following form and by also adding the item to the roster (buddy list) before requesting the subscription

<presence xmlns='jabber:client' from='a@gmail.com' type='subscribe' to='b@gmail.com'><sub:invitation xmlns:sub='google:subscribe'><sub:body/></sub:invitation></presence> 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top