1
votes

I am facing an issue with the presence status, following the documentation and XMPPframework example code. I have written a chat application.

Problem : When the user 1 & 2 are online I get the status successfully and they can chat with each other. However when the user 2 goes physically offline via (Wifi OFF / 3G Off) User 1 is not getting the offline status from XMPP and hence what ever messages are sent from that instant of time are lost when the user 2 comes online.

  1. It seems since the user 2 is not notified or stored as offline in XMPP and hence its not storing the offline messages to push back to user 2 when it comes online.

  2. I have tried to resolve this by explicitly writing a [goOffline] call to XMPP, however the call is shown in 'SEND log' for 'user 2' but not received in 'RECV log' in user 1 from XMPP, due to which the message are lost in between.

  3. Also tried with other sources replies.

    • Set status for presence available and send XMPP
    • priority changed with values non-negative
    • XMPPArchiving work but this is not what I wanted.
    • Server side Mod_zero push enables but get only first message push notification sometimes.
    • Setting limit on ejabberd.cfg file for users and offline message limit.
    • request for offline message pull.

Can anyone help me with this?

2

2 Answers

0
votes

Sounds like your problem is at server level. The server thinks that the user is online so it sends the message but nobody gets it. This does not really have a simple solution.

1. The best solution would be delivery receipts. Where basically when the message is sent to your client, your client returns a confirmation of delivery receipt. If the server does not get that receipt it would resend the message every n time. Depending on your XMPP server you might find a already made solution, of not you would have to roll out your own.

2. A possible hack would be to have your server always store and deliver last 10 messages and then at client side you discard repeated... This also depends on your server implementation. XMPP MUC and PubSub have resources along these lines.

For a long term scalable solution, you'll need to deal with this both at server and client level.

1
votes

This is very typical situation where client losses network but server can't detect that it is offline.

To detect status of each client, server need to send PING packets to every client and wait for response.
If client responds then fine otherwise server will mark that client as offline and every other online client will be informed automatically.

Here is PING Module implementation for ejabberd XMPP Server (hope you are using ejabberd server):

mod_ping: 
send_pings: true
ping_interval: 10
timeout_action: kill
ping_ack_timeout: 10

This has to be written in ejabberd.yml configuration file.

At client side also we need to enable ping module to respond to server pings as:

private var xmppPing: XMPPPing?
xmppPing = XMPPPing()
xmppPing!.activate(xmppStream!)

This code has to be written while we setupStream() for iOS.

For detailed info, please go through mod_ping documentations.