XMPP: Client Receives Notifications Only From Resource Bound - xmpp

I'm building an XMPP client in Python. The client needs to get notifications from multiple pubsubs. During session initialization, the client must bind to a resource.
For example, the client could bind to pubsub.sales.
<body rid="34314915"
sid="fe63566533334135bb2edf70b80a62743416b584"
xmlns="http://jabber.org/protocol/httpbind">
<iq id="KVwaFGvr+M53"
type="set"
xmlns="jabber:client">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
<resource>pubsub.sales</resource>
</bind>
</iq>
</body>
When I do that, the client only gets messages from the resource to which it is bound. How can I get notifications from other pubsubs?

The problem was related to presence. Here is what the client was sending:
<body rid="34314917"
sid="fe63566533334135bb2edf70b80a62743416b584"
xmlns="http://jabber.org/protocol/httpbind">
<presence xmlns="jabber:client">
<priority>-1</priority>
</presence>
</body>"""
When priority is negative, the client only receives notifications sent to the full JID. I set the priority to 7 and now the client gets notifications from the all pubsubs that are subscribed.

Related

Chat process in XMPP Openfire server using Android application

I’m using Openfire XMPP server for a android chat application. I can connect and login to the server using my app.
Now I want to know how to send friend request and accept friend request in this chat application.
I can fetch all the user from server but I want to know the process of starting a chat.
Thanks in advance.
The processes are a bit more complex than it looks to add/accept friend requests you need to do some juggling with presence and and roster iq stanzas.
I'll try to give you an indication about what stanzas are sent/received using contacts operations below.
1. Add contact
To add a contact you need to send a `subscribe` stanza.
<presence xmlns="jabber:client" to="you#app.com/123" id="9VO8j-1" type="subscribe" from="me#app.com/1234" />
1.1. Request accepted
When adding a contact and the other app "accepts the request" you receive two stanzas:
1. <presence xmlns="jabber:client" from="you#app.com/123" id="9VO8j-1" type="subscribed" to="me#app.com/1234" />
2. <presence xmlns="jabber:client" from="you#app.com/123" id="9VO8j-2" type="subscribe" to="me#app.com/1234" />
3. <presence xmlns="jabber:client" from="me#app.com/1234" id="9VO8j-3" type="subscribed" to="you#app.com/123" />
1.2. Request Denied
When the request is denied you receive an "UNSUBSCRIBED" stanza.
Example: <presence xmlns="jabber:client" from="you#app.com/123" id="9VO8j-1" type="unsubscribed" to="me#app.com/1234" />
2. Accept contact request
1. <presence xmlns="jabber:client" from="me#app.com/1234" id="9VO8j-1" type="subscribed" to="you#app.com/123" />
2. <presence xmlns="jabber:client" from="me#app.com/1234" id="9VO8j-2" type="subscribe" to="you#app.com/123" />
3. Deny contact request
<presence xmlns="jabber:client" from="me#app.com/1234" id="9VO8j-1" type="unsubscribed" to="you#app.com/123" />
4. Remove contact
When you "Delete" a contact you should be in fact be "deleting" it locally in your app and from the roster.
This is done by sending two stanzas:
1. <presence xmlns="jabber:client" from="me#app.com/1234" id="9VO8j-3" type="unsubscribe" to="you#app.com/123"/>
2. <iq from='me#app.com/1234' id='ah382g67' to='you#app.com/123' type='set'>
<query xmlns='jabber:iq:roster' ver='ver34'>
<item jid='you#app.com/123' subscription='remove'/>
</query>
</iq>
Note: The use-cases described above do not include all the iq:roster stanzas associated to the presence stanzas. These are sent automatically by the server whenever a contact changes the subscription and ask types.
For a better understanding of how the these workflows work in details I suggest you read the latest RFC (implemented by your server). You can find it on the office site.
See section 3. Managing the roster.

how to retrieve items from pep pubsub xmpp protocol

How can I retrieve items using PEP pubsub XMPP protocol? I don't know how to retrieve history of PEP events. I tried with this stanza, but I am getting an "item not found" error.
<iq type='get'
from='admin#domain.ddns.net'
to='pubsub.domain.ddns.net'
id='items1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<items node='http://jabber.org/protocol/tune'/>
</pubsub>
</iq>
You're sending the request to pubsub.domain.ddns.net, i.e. a Pubsub service, but when using PEP, you need to send the requests to the bare JID of the contact, e.g. user#domain.ddns.net. See XEP-0163 for more details.

Retrieving offline messages not working -XMPP wokkel

I have an XMPP chat client using wokkel and twisted and it works fine, but when a user comes online, I send this stanza to get the messages a user received while offline:
<iq type='get' id='fetch1'><offline xmlns='http://jabber.org/protocol/offline'><fetch/></offline></iq>
Other messages send and receive just fine but this stanza never returns anything. Any ideas how to debug or what the issue is? (These are google talk users)
Update: Google talk in theory supports XEP-0136 (archiving). When you get a list of support features you get:
<feature var='http://jabber.org/protocol/archive#otr'/>
<feature var='http://jabber.org/protocol/archive#save'/>
However, when I then follow this: http://xmpp.org/extensions/xep-0136.html#manage-retrieve
as to how to retrieve archived messages. I send the following stanza:
<iq type='get' id='page1'><retrieve xmlns='urn:xmpp:archive'/></iq>
[Whether or not I include the tag part of their example, I get a feature not support error back from Google's XMPP server]
<iq xmlns='jabber:client' to='x#gmail.com/7EBA7137' type='error' id='page1'>
<retrieve xmlns='urn:xmpp:archive'/><error code='501' type='cancel'>
<feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>

strophe.js - messages are not delivered on chrome

I'm creating custom xmpp chat application with use of Strophe.js. The communication between browser and desktop client (Adium) works perfectly. I can send messages via browser to Adium and from Adium to the browser. There is yet the problem with browser-browser communication at some point as messages are sent but not delivered. It seems it's just Google Chrome problem.
What's interesting is the fact that <presence> stanzas are sent and delivered fine. We use ejabberd as the server daemon.
This is the presence stanza I'm sending from one account:
<presence type="away" xmlns="jabber:client">
<show>away</show>
<status/>
</presence>
and what I receive on the other:
<presence xmlns="jabber:client" from="test1#domain.com/3917283126133167196759537" to="test2#domain.com/1563391996133167110798391" type="away">
<show>away</show>
<status/>
</presence>
also the message stanza I send:
<message from="test1#domain.com/267172122813316722921543" to="test2#domain.com" type="chat" id="4915" xmlns="jabber:client">
<active xmlns="http://jabber.org/protocol/chatstates" />
<body>Testing...</body>
</message>
and nothing is received on Chrome...
EDIT:
The problem was with escaping some characters. Chrome did not let them unescaped due to security issues.
The type="away" in your initial presence is not valid. Omit the 'type' attribute for available presence. Set type="unavailable" when you are going offline.
Because your presence is invalid you are not marked as available, and you will not receive any messages addressed to your bare JID.
Update: To clear any confusion about what I mean by the above (see comments)...
The 'type' attribute on this stanza is invalid:
<presence type="away" xmlns="jabber:client">
<show>away</show>
<status/>
</presence>
It is otherwise fine. There are two types of presence a client may send, available and unavailable. Standard available presence has no 'type' attribute. Unavailable presence has type="unavailable". The actual status of the user (away, etc.) is signaled via the <show/> and <status/> elements, not the 'type' attribute.
To make it the above stanza a valid available presence, just remove type="away":
<presence xmlns="jabber:client">
<show>away</show>
<status/>
</presence>

Ejabberd Stanza Execution Order (Grouped together)

I am trying to find out the execution order of XMPP stanzas, I am using Strophe + Ejabberd and if I send a request like this.
<body rid='someRID' xmlns='http://jabber.org/protocol/httpbind' sid='someSID'>
<message to='someUser#someDomain' type='chat' xmlns='jabber:client'>
<body>123</body>
</message>
<presence type='unavailable' xmlns='jabber:client' />
</body>
Presence stanzas is always executed first and message stanza later. Is there a way to specify order or something like that so that Message stanza is executed first and Presence later.
Thanks
It's a bug in the server. RFC 6120, Section 10.1 says:
An XMPP server MUST ensure in-order processing of the stanzas and
other XML elements it receives over a given input stream from a
connected client or remote server.