Lossing messages due to connection loss through openfire
Asked Answered
L

2

7

Turning off internet on mobile device directly causes problems in my chat application. Messages are not stored in openfire offline table as Openfire still shows me online on abrupt disconnection from the server. when a relogin attempt is made the messages that were sent in that period are lost.

I am working on a chat application,after login to openfire I am able to chat and other users can see me online but the problem is if one user losses the connection like WIFI off,In such situation Openfire is not showing my status as offline and it still shows Online which results in message packet loss.

Please provide me the solution I am unable to resolve it.

On a sidenote how whatsapp and other apps send messages. Do they use message storage strategy on server and acknowledgement or am I missing something here.

Lubow answered 2/7, 2014 at 15:10 Comment(0)
T
1

Both client and Server needs to acknowledge that messages were sent & delivered, say for instance you send a message to someone else, what you can do here is that you save this message on your server, from server this message will be sent to receiver and wait for an acknowledgement by the receiver that the message was delivered, once you get acknowledgement - delete the message from the server.

How whatsapp do it? I found this answer by Michael Donohue on Quora

Whatsapp works on store and forward, The WhatsApp client will store any message you send, and keep trying to send it to the WhatsApp servers. When a WhatsApp mobile app connects to the chat servers, the store-and-forward process occurs in both directions. The client sends any pending messages in it's mesage store to the server, while the server sends all the accumulated messages destined for that client to the client. This process is done on an acknowlegement basis. This means messages are sent repeatedly until the other side acknowledges receipt of the message. server drops messages once they are acknowledged - there is no long term storage. Whereas the client will update the UI to double-check status once the ack arrives, but will keep the message.

Telespectroscope answered 2/4, 2015 at 13:44 Comment(0)
P
-1

In android client using Smack framework, you must disable Stream Mananement just after creating XMPPTCPConnection and before run connection.login().

connection.setUseStreamManagement(false);

I had this problem and with this code was solved.

Pricefixing answered 21/2, 2018 at 14:52 Comment(1)
If userStreamManagement set false so we can't received message acknowledgement status on server side.Carmelinacarmelita

© 2022 - 2024 — McMap. All rights reserved.