Problem creating a chat room with XMPP in an iOS app - iphone

I have an iphone app where I want to use chat rooms. I've installed an XMPP server (ejabberd) and downloaded the XMPP framework for iOS from google code (http://code.google.com/p/xmppframework/). The server and client work as expected, since I'm able to log in and send chat messages between two users.
However, when I try to create a chat room using the createOrJoinRoom method of the XMPPRoom class (in XEP-0045), I don't get any reply from the server and the chat room is not created.
I've debugged to see what kind of package is sent to the server and it looks like this:
<presence from="test2#beta.bogus.net/mynick" to="muumit15#conference.beta.bogus.net">
<x xmlns="http://jabber.org/protocol/muc"/>
</presence>
I get no error message back but the chat room (muumit15) is not created. At the same time I can use e.g. Adium client to create a chat room and it succeeds. The server has been configured so that every user has a right to create chat rooms.
Any ideas? I even tried sniffing the TCP/IP traffic sent by the Adium client but that was encrypted/compressed/binary so I couldn't see what kind of packages it is sending.

See section 7.2.2 of XEP-0045, particularly Example 18:
<presence
from='hag66#shakespeare.lit/pda'
to='coven#chat.shakespeare.lit/thirdwitch'>
<x xmlns='http://jabber.org/protocol/muc'/>
</presence>
Note that the to address MUST contain a resource, and yours doesn't. The resource is the string after the /, which is used as your nickname in the room. For more information on the XMPP address format, see RFC 6122.

Related

How can I get last message of each conversation(per JIDs) from openfire?

I'm developing an instant messaging app on android with SMACK library that uses OPENFIRE as a xmpp server. I want to get last message of each conversation from MessageArchiveManager in openfire server that was enabled by MONITORING SERVICE plugin(based on XEP-0313).
I know that mamManager.queryArchive() can gets the messages that related to specific jid or can get a specific number of messages that exists in server(with no custom sepration), but we suppose that smack doesn't knows which JIDs has conversation on server!
One solution is that send request per each ROSTER entry, but it has heavy cost when it contains numerous contacts and perhaps we have a conversation with anybody out of Roster. Is there any way or plugin or another extension to do this?

Getting online presences for Facebook Chat

I'm using libpurple to connect to the FB chat. The problem is that I do not get online presences from friends who are online the via mobile Facebook application.
But if such a friend sends me a message, I get both the message and online presence for him at the same time.
It looks like this:
(14:23:08) jabber: Recv (ssl)(191): <message from="-mybyddyid#chat.facebook.com" to="myownid#chat.facebook.com/b94353f3_4CE87B53BB319" type="chat"><composing xmlns="http://jabber.org/protocol/chatstates"/></message>
(14:23:10) jabber: Recv (ssl)(188): <message from="-mybyddyid#chat.facebook.com" to="myownid#chat.facebook.com/b94353f3_4CE87B53BB319" type="chat"><active xmlns="http://jabber.org/protocol/chatstates"/></message>
(14:23:11) jabber: Recv (ssl)(166): <presence from="-mybyddyid#chat.facebook.com" to="myownid#chat.facebook.com/b94353f3_4CE87B53BB319"><x xmlns="vcard-temp:x:update"><photo/></x></presence>
So I am wondering whether it's my fault or the limitation Facebook Chat implementation.
I think there will be a delay for presence updates. Maybe you can check this out asking your friends not to send a message and waiting for the presence to change. From the facebook chat developers page [1] it seems that there will be a delay after which the presence will get updated when you change it.
Also, from the same page, one of the limitations is that the facebook chat server doesn't support presence probes. An XMPP server sends presence probes to contacts if it doesn't already have the presence information of the contacts after the user logs in and sends the initial presence (see section 5.1.1 of RFC 3921 [2], and section 4.3.1 of RFC 6121 [3]).
If the server cant send presence probes, it may not have the presence information of the contacts. I dont know how the facebook chat server was implemented, but I am guessing that when the contact does something (like sending a message/updating the presence), the server assumes that the contact is online and sends the presence. (I may be wrong here, someone correct me if I am!)
References:
[1] http://developers.facebook.com/docs/chat/
[2] http://xmpp.org/rfcs/rfc3921.html
[3] http://xmpp.org/rfcs/rfc6121.html

What does "stalker status" mean in chat applications?

I have created an XMPP chat application for Android and iPhone. While testing the app in jwchat.org, users who are created from iPhone devices are shown as 'stalker', and Android usernames are shown as online / offline. What does 'stalker' mean? Because of this, messages are sent and received from Android to iPhone, but iPhone devices' messages are not recieved by Android devices. Can anyone please help me?
"Stalker" is an unfortunate term that is embedded in the user interface of your client, not a standard part of the protocol. It likely refers to people who are in your roster as type="from", which indicates that they are subscribed to your presence but you are not subscribed to their presence. If you want to change this state, send them:
<presence type='subscribe' to='stalker#example.com'/>
Once they accept with:
<presence type='subscribed' to='you#example.com'/>
You should have each other in the type="both" state on one anothers' rosters.
It sounds like a presence problem on the iPhone app -- that it is successfully logging in/authenticating to the xmpp server, but then failing to send an xmpp presence stanza.
Do you have any traces of the xmpp communication?

user profile from XMPP iPhone

I am using XMPP for chatting in my iPhone application, I need to retrieve the profile of every user in buddy list, like phone number, street address etc.
How can I get started?
While XEP-54 can be used for this purpose, PLEASE do not spam the network by making vcard-temp requests for everyone on your roster every time your client logs in. Since you haven't told us what client library you're using, all we can do is provide you with the protocol you need to send:
<iq id='v1'
type='get'>
<vCard xmlns='vcard-temp'/>
</iq>
Note that XEP-54 is about to be obsoleted by XEP-292, but it will take several years for that transition to take place.

Send XMPP message without starting a chat

I am basically writing a XMPP client to automatically reply to "specific" chat messages.
My setup is like this:
I have pidgin running on my machine configured to run with an account x#xyz.com.
I have my own jabber client configured to run with the same account x#xyz.com.
There could be other XMPP clients .
Here is my requirement:
I am trying to automate certain kind of messages that I receive on gtalk. So whenever I receive a specific message eg: "How are you" , my own XMPP client should reply automatically with say "fine". How are you". All messages sent (before and after my client replies) to x#xyz.com but should be received by all clients (my own client does not have a UI and can only respond to specific messages.).
Now I have already coded my client to reply automatically. This works fine. But the problem I am facing is that as soon as I reply (I use the smack library), all subsequent messages that are sent to x#xyz.com are received only by my XMPP client. This is obviously a problem as my own client is quite dump and does not have a UI, so I don't get to see the rest of the messages sent to me, thereby making me "lose" messages.
I have observed the same behavior with other XMPP clients as well. Now the question is, is this is a requirement of XMPP (I am sorry but I haven't read XMPP protocol too well). Is it possible to code an XMPP client to send a reply to a user and still be able to receive all subsequent messages in all clients currently listening for messages? Making my client a full fledged XMPP client is a solution, but I don't want to go that route.
I hope my question is clear.
You may have to set a negative presence priority for your bot..
First thing to know is that in XMPP protocol every client is supposed to have a full JID. This is a bare JID - in your case x#xyz.com with a resource in the end e.g. x#xyz.com/pidgin or x#xyz.com/home (where /pidgin and /home are the resource). This is a part of how routing messages to different clients is supposed to be achieved.
Then there are the presence stanzas. When going online a client usually sends a presence stanza to the server. This informs about e.g. if the client is available for chat or away for lunch. Along with this information can be sent a priority. When there are more than one clients connected the one with the highest priority will receive the messages sent to the bare JID (e.g. ClientA(prio=50) and ClientB(prio=60) -> ClientB receives the messages sent to x#xyz.com). But there are also negative priorities. A priority less than 0 states that this client should never be sent any messages. Such a stanza might look like this
<presence from="x#xyz.com/bot">
<priority>-1</priority>
</presence>
This may fit your case. Please keep in mind it also depends on the XMPP server where your account is located, which may or may have not fully implemented this part of the protocol.
So to summarize: I recommend you to look through the Smack API how to set a presence and set the priority to <0 for your bot client right after it connected.