Hello,
I'm new to XMPP, and I'm working on developing an XMPP client in Javascript. (I know this sounds like a silly thing to do... never mind why.) I'm using ejabberd as my server to test against. I'm running it on my local machine and running two copies of my client, who attempt to communicate with each other through the server.
I've noticed that sometimes, even though the first client has sent a message stanza only once, the receiving client will get this stanza multiple times. Especially if it disconnects and reconnects, it will often get another copy of the old message stanza immediately. Sometimes it will get multiple copies of the same message stanza in a row.
Is this a bug, or a feature? I can't find anything about it in the documentation, but it seems like maybe the server is purposefully sending out repeats of the message in case the receiving client missed the original message when it was offline, as a helpful feature. Is there perhaps some kind of acknowledgement message that the receiving client should be sending to the server to say "OK, I got this message, you don't need to send it again"? I haven't seen anything about such an acknowledgement in the XMPP specs. Should I be expecting the duplicate messages to occur, and write some code to detect and throw away duplicates at the application level?
Thanks a lot for your help,
--Jono DiCarlo
You're right: neither XMPP
You're right: neither XMPP or ejabberd implement stanza ACK. The only messages stored by ejabberd for later delivery are messages sent to an offline contact: they are stored, and sent to the contact when he comes back online.
You can install a packet sniffer like Wireshark. Listening in localhost 'TCP port 5222', and check what's going on there. Wireshark can recognize XMPP traffic.
You can also try mixing a normal desktop client (Gajim, Psi, Tkabber...) and your JS client: send, receive.
If you progress in your investigation and consider the problem looks to be in ejabberd, please try to write 'reproduction instructions: install ejabberd x.x.x, create account test1 and test2, login in test1 with the jabber client X version X, ...' This way we can reproduce the problem, and debug ejabberd internals in a controlled environment.