Support #8500

Historical message duplication

Added by Teymon zhan 3 months ago. Updated 3 months ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Source Code Disclaimer:


A user's network is unstable and the connection drops. The Tigase server does not know that A is offline ,
When B sends message to A,
Tig_ma_msgs table holds two messages, the sending record of B and the receiving record of A
But A didn't actually get the message,
An offline message record is saved in the offline message table msg_history.
When A connects to the Tigase server again and receives an offline message, another record of A receiving message is written in the tig_ma_msgs table, Then ,
When A looks up the history message, it will see two messages sent by B to A, which are repeated.

I don't know if I'm making myself clear?


#1 Updated by Andrzej Wójcik IoT 1 CloudTigaseTeam 3 months ago

  • Status changed from New to Feedback
  • Assignee set to Teymon zhan

What are particular settings of your installation? ie. how long it is allowed to wait for XMPP client to resume?
Do you have any custom code?

I'm asking about that because Tigase Message Archiving Component contains code for possible duplicate message detection if the message is redelivered and this solution works quite well for us on many installations.

One of the possible issues may be:

  • too big allowed resumption time
  • message without the id attribute (if available duplicated detection works far better)
  • XMPP client waits too long before acknowledging delivered messages
  • time drift between XMPP servers withing the cluster or between XMPP servers and the database server

#2 Updated by Teymon zhan 3 months ago

--virt-hosts =ip
--debug = server


--comp-name-2 = muc 
--comp-class-2 = tigase.muc.MUCComponent 

--comp-name-3 = pubsub 
--comp-class-3 = tigase.pubsub.PubSubComponent 







## The following configuration does not work

The client is the BOSH protocol:

connection = new Strophe.Connection(BOSH_SERVICE, {keepalive: true});
connection.connect(jid, password, onConnect);

The XMPP server version is 7.1.4 , the server and database server are on the same machine. No cluster is deployed. I don't have any custom code. If the client network is normal, the messages sent and received are normal. If client the network is unstable, there is a problem of duplicate receipt of messages.


#3 Updated by Andrzej Wójcik IoT 1 CloudTigaseTeam 3 months ago

In this case usage of BOSH and not delivery messages by BOSH is actually root cause of this issue. If the message is not delivered to the recipient by BOSH component it sends it back for redelivery so in fact, Tigase XMPP Server is processing this message twice and that is causing duplication of messages.

Do you have any requirement to use BOSH for connecting to Tigase XMPP Server? I'm asking as WebSocket based connections are a lot faster, are using fewer resources and more reliable when StreamManagement is enabled on them. (and thanks to StreamManagement, message duplication is not happening due to different processing flow which cannot be applied to BOSH based connections).

#4 Updated by Teymon zhan 3 months ago

I changed the connection.

connection = new Strophe.Connection('ws://ip:5290', {keepalive: true});

Message duplication did not occur.

But another problem arises :

After A user's network is unstable and the connection drops, the message sent by B will not be saved as an offline message (msg_history did not insert data, Tig_ma_msgs table holds two record , the sending record of B and the receiving record of A ). When A reconnects, there is no new message to remind. Then , when querying the history record of A user, there is the sending message record of B user.

I hope the solution is that after A user's network is unstable and the connection drops, the message sent by B is saved as an offline record, and when user A reconnects, he receives an offline message reminder. When getting the history message of A, there is the message record sent by user B.


Also available in: Atom PDF