I''ve been having problems with the subscription process using my client - xmpp

Im using Jabber-Net API to make a GMail client. I've been having problems with the subscription process using my client as it always returning the "subscription=none" and "ask=none". When i subscribe a new user, it works fine but, subscribing/ unsubscribing users very frquently from roster makes the users stop to send subscription request with "to/ from/ both" or etc.
I have discovered that, "CONTACT" always receives a packet like this:
<iq type="set">
<query xmlns="jabber:iq:roster">
<item
jid="jabberuser#host"
subscription="none"
ask="none"/>
</query>
</iq>
Any prompt answer will be much appreciated..

Are you sending a presence subscription?
<presence type='subscribe' to='jabberuser#host'/>

Related

Deny messages from non-roster users in Openfire

How do I only allow contacts who are on my roster list to send me messages?
Is there any XEP responsible to do that? Or will I need to do this client-side?
Yes, OpenFire supports XEP-0016: Privacy Lists (see this question), which can be used to block stanzas according to various criteria.
You can't explicitly block stanzas for contacts not in your roster, but you can block by subscription status none, which can more or less accomplish the same goal. You could send something like this:
<iq from='romeo#example.net/orchard' type='set' id='msg3'>
<query xmlns='jabber:iq:privacy'>
<list name='message-sub-example'>
<item type='subscription'
value='none'
action='deny'
order='5'>
<message/>
</item>
</list>
</query>
</iq>
This creates a privacy list called message-sub-example, containing a rule to block any messages from contacts with subscription type none, including contacts not in the roster. For this list to take effect, you need to make it the active list:
<iq from='romeo#example.net/orchard' type='set' id='active1'>
<query xmlns='jabber:iq:privacy'>
<active name='message-sub-example'/>
</query>
</iq>

How to join multiple rooms by just sending one <presence> message to ejabberd server

For example, I have 20 rooms to join. The simple solution is to send 20 message to each room id. Considering the performance, this is bad.
I want to join the 20 rooms by just sending one <presence> message, how to achieve this? Writing a module to hook the custom <presence> message? But I do not know how to write this kind of module.
In XEP-0045 Multi User Chat, there is no way defined to join 20 chat rooms with a single presence packet.
However, by combining other XMPP Extension with Multi User Chat, you can definitely achieve this in pure XMPP, without the need to write custom ejabberd extensions.
You can rely on XEP-0033 Extended Stanza Addressing, you can send an XMPP packet to several recipient. It also works with presence as shown in this example.
ejabberd configuration
XEP-0033 Extending Stanza Addressing is supported as default since ejabberd 15.04. Make sure you have enable the feature by adding mod_multicast in ejabberd configuration modules section:
modules:
...
mod_multicast: {}
When the service is enabled, you should have a new service (as default named multicast.example.net) on the server supporting the feature http://jabber.org/protocol/address:
<iq type='get'
to='multicast.example.net'
id='info1'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
and response is:
<iq from="multicast.example.net" type="result" to="test#example.net/laptop" id="info1">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="service" type="multicast" name="Multicast"/>
<feature var="http://jabber.org/protocol/disco#info"/>
<feature var="http://jabber.org/protocol/disco#items"/>
<feature var="vcard-temp"/>
<feature var="http://jabber.org/protocol/address"/>
</query>
</iq>
Usage
Once enabled, it is easy to send a presence packet targeting several MUC rooms:
<presence to='multicast.example.net'>
<addresses xmlns='http://jabber.org/protocol/address'>
<address type='bcc' jid='testroom#conference.example.net/Usernick'/>
<address type='bcc' jid='testroom2# conference.example.net/Usernick'/>
</addresses>
</presence>
You will thus see that you are joining several rooms at the same time.
Issues
XEP-0033 did not specifically mention that use case and the module had not been testing to join multiple rooms. While writing this example I found that when disconnecting, user does not properly leave the rooms he had joined.
It means you have to wait for the following Github issue to be fixed before the feature is usable in production: Broadcast presence change after multicast presence packet.

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>

Facebook Chat (XMPP) XEP 0080 support

I have being checking out using a prototype test program the capabilities of the XMPP Facebook Chat, X-FACEBOOK. It worked great using a geoloc message XEP 0080 with Gmail servers, but when i try to send the same XML structure through the X-FACEBOOK, it trims the message and removes the GeoLoc node.
I wanted to ask if someone knows if its possible to send XEP 0080 messages in X-FACEBOOK and if so what structure should I use so the Facebook Chat XMPP Server won't trim the GeoLoc info.
Sent XMPP geoloc message:
<message to="-100002578491827#chat.facebook.com" from="4yony4#chat.facebook.com/19256ca9_4C5CC12947646" type="chat" xml:lang="en">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="http://jabber.org/protocol/geoloc">
<item id="">
<geoloc xmlns="http://jabber.org/protocol/geoloc">
<lat>40.488137</lat>
<lon>-3.397623</lon>
<timestamp>2012-07-27 09:09:50 GMT</timestamp>
<msgType>0</msgType>
</geoloc>
</item>
</items>
</event>
<body>
</body>
Received message by client:
<message xmlns="jabber:client" from="-1177157556#chat.facebook.com" to="" type="chat">
<active xmlns="http://jabber.org/protocol/chatstates"/>
<body></body>
</message>
Any solution or opinion will be greatly appreciated.
Well, changed the XML to resemble the one you posted, without the pub sub, and still the same problem, the message received in the recipient lacks all the namespaces under the GeoLoc node, which I think is a result of the Server not supporting that format. I can try and use the IQ subscriber option, thing is that I prefer to find a solution on which I can directly send the info to a user.
If there is a possibility, even a small one in which i may be able to send information regarding GeoLoc from User A to User B in Facebook Server it may be of great help, if not well i guess i will have to accept it.
Thx for the help BTW.
When I was testing facebook XMPP connection, it did not support almost any extensions and blocked any custom tags on server. It was able to send basic presences, basic messages, vcards and that was about all it could do.
Pubsub events should be sent to services. Modern XMPP servers also support PEP extension and you can send pubsub to servers itself. In other cases, use message with target user as Robin have advised.
I do not think facebook has any server with pubsub. Also i think it still filters any unsupported namespaces. Feel free to prove me I am wrong, it is more than year since I last tested it.
These are not the same message.
The received message is simply an indicator of the users chat state, as defined in XEP-0085 and has no direct relationship to the message you sent. That doesn't mean that the first didn't potentially trigger the second, whatever library you are using may have sent the chatstate as well when you sent the message. This type of message is commonly used in chat clients to indicate that someone you are chatting with is typing a message.
The problem is probably that the message you are sending is in fact a PEP message. This is meant to be sent by the PEP service in the server, not from a client. I don't know if Facebook supports PEP or not, but I would guess that it is being filtered out due to your incorrect usage of a known namespace. PEP or Pubsub are the recommended ways of publishing geolocation information, but to utilize those you have to send an IQ packet to the service, not a message to the other client.
Try this instead (Not saying it will work, but at least the pubsub stuff is stripped):
<message to="-100002578491827#chat.facebook.com" from="4yony4#chat.facebook.com/19256ca9_4C5CC12947646" type="chat" xml:lang="en">
<geoloc xmlns="http://jabber.org/protocol/geoloc">
<lat>40.488137</lat>
<lon>-3.397623</lon>
<timestamp>2012-07-27 09:09:50 GMT</timestamp>
<msgType>0</msgType>
</geoloc>
<body>
</body>
</message>
I want to second Pihhan. It seems like the Facebook XMPP servers restructure messages to contain only the message body, date, and timestamp. I think they do that to keep it identical to their comment graph objects.
It is annoying, but I suspect it is deliberate. After all, their Graph is the main issue, not XMPP.

XMPP multi-user-chat get user list

get a list of all users and the status of XMPP multi-user-chat
I do so
<iq from='hag66#shakespeare.lit/pda'
id='kl2fax27'
to='coven#chat.shakespeare.lit'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
getting a list but without status.
I need for all users on the statuses to know?
Please read XEP-0045, which describes the multi-user chat (MUC) protocol. You need to join the room:
<presence
from='hag66#shakespeare.lit/pda'
to='coven#chat.shakespeare.lit/thirdwitch'>
<x xmlns='http://jabber.org/protocol/muc'/>
</presence>
You'll then get a presence stanza from each occupant of the room with their current status:
<presence
from='coven#chat.shakespeare.lit/firstwitch'
to='hag66#shakespeare.lit/pda'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='owner' role='moderator'/>
</x>
</presence>
<presence
from='coven#chat.shakespeare.lit/secondwitch'
to='hag66#shakespeare.lit/pda'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='admin' role='moderator'/>
</x>
</presence>
And before you ask, no, there is no way to tell when you're "done" receiving these notifications, since users may come and go at any time. You are now subscribed to the presence changes of the occupants, and have to keep track of what is current on the receiving side.
Reading through the XMPP RFC, I see that statuses are conveyed by presence messages, and that you ask another entity to report its status now (rather than waiting for it to tell you in a broadcast) by sending a probe status request to which you'll get a directed response (§5.5 of the RFC gives some examples). It's up to you to interpret what they say back correctly, of course…