Message loss due to loss of connection through openfire

Disabling the Internet on the mobile device directly causes problems in the chat application. Messages are not stored in the openfire offline table, as Openfire still shows me online when it suddenly disconnects from the server. If you try to retry, messages sent during this period are lost.

I’m working on a chat application, after logging into openfire, I can chat, and other users can see me on the network, but the problem is that one user will lose the connection, for example, WIFI. In this situation, Openfire does not show my status as offline, and it still shows the Internet, which leads to the loss of message packets.

Please provide me with a solution that I cannot solve.

In the sidebar, like whatsapp and other applications send messages. Do they use a strategy for storing messages on the server and confirmation, or am I missing something here.

+7
android openfire
source share
2 answers

Both the client and the server must acknowledge that the messages were sent and delivered, for example, you send a message to someone else, what you can do here is that you save this message on your server, from the server this message will be sent to the receiver and wait for confirmation by the recipient that the message was delivered, after receiving confirmation - delete the message from the server.

How to do it? I found this answer by Michael Donoghue in Quora

Whatsapp works in the store and forwarding, the WhatsApp client will store any sent message and continue to try to send it to WhatsApp servers. When the WhatsApp mobile app connects to chat servers, the storage and forwarding process takes place in both directions. The client sends any pending messages in the mesage repository to the server, and the server sends all accumulated messages intended for this client to the client. This process is based on recognition. This means that messages are resent until the other party acknowledges receipt of the message. the server discards messages after they are confirmed - there is no long-term storage. Whereas the client will update the user interface to double check the status after ack arrives, but will save the message.

+1
source share

In the Android client using Smack, you must disable Stream Mananement immediately after creating the XMPPTCPConnection and before running connection.login ().

connection.setUseStreamManagement(false); 

I had this problem and this code was resolved.

-one
source share

All Articles