ejabberd and lost messages, possible “solutions”
Being the tinfoil hat I am I obviously don’t like nor use whatsapp, some time ago I set up my own XMPP server and made a bunch of close friends switch to it.
There are multiple clients for every platform, my personal preference goes to Xabber on Android and Pidgin on GNU/Linux; both support OTR encryption and all around are pretty decent clients.
The only real issue we had so far is the very annoying problem of lost messages; if the internet connection is stable and decent the problem will very likely never come up, too bad that mobile phone internet connection is everything but stable.
Every time there is a switch between EDGE, 3G, HSDPA and 4G the mobile phone is out of reach for some seconds (some time much more than just some).
The switch between let’s say 3G and HSDPA is not predictable, so the client has physically no time to notificate the server that he is about to close the connection and on the other hand the server also has some trouble knowing if someone suddenly disconnect.
Here comes XEP-199 a.k.a. XMPP ping, it is used to probe the clients connection state every X seconds, in my ejabbed (the XMPP server I use) configuration it is set to 60 seconds, so every 60 seconds the server ping every client, if after 32 additional seconds a client has not replied it will be considered as disconnected and any further message sent from everyone to it will be cached by the server and resent the next time the client will be back online.
Enable XEP-199 in ejabberd is pretty easy…
[root@CentOS ~]# vi /etc/ejabberd/ejabberd.cfg
…find mod_ping section (line 526 in my configuration file) and set the desired options, mine are as follows:
{mod_ping, [
{send_pings, true},
{ping_interval, 60},
{timeout_action, kill}
]},
So far so good, except that this actually doesn’t solve the problem, even if we decide to send a ping every each second there will always still be a 33 seconds possible black window in which a client will be considered online even if it actually isn’t.
The problem is actually pretty tricky and far from easy to solve, as a matter of fact as per today there is no actual way to solve it, even whatsapp, which should be based on XMPP too, is affected by this issue.
Here comes XEP-184 a.k.a. Message delivery receipts, the name is pretty much self explanatory: every time a message is sent the receiver client sends back an acknowledge like signal to the sender, this way at least we (the users) can check if a message has really been delivered or not.
Honestly I don’t understand why the clients are deputed to do this job while it would make more sense if the server did it, so in case a message has not really been delivered it can be resent automatically without the user having to do it manually.
Anyway, Xabber already implements XEP-184, when a message is correctly delivered a green check appears on the yellow mail icon placed on the upper left corner of every message: no check means message not delivered.
On the other hand, and even this time don’t ask me why, Pidgin by default doesn’t include a plugin for XEP-184, luckily a nice guy wrote it (available for both GNU/Linux and Windows).
The source/precompiled DLL for Windows can be found here, to compile it on Fedora 20 libpurple-devel and pidgin-devel are needed, then it’s just a matter of make and make install.
Open Pidgin and enable the plugin from plugins page; from now on, if the receiver client support XEP-184 too, a check will appear next to every message sent and correctly delivered.
.:. Update
Finally the light at the end of the tunnel: https://uwot.eu/install-and-configure-ejabberd-xmpp-server-on-centos/