tigase.server.xmppclient.ClientConnectionManager#serviceStopped
-> tigase.server.xmppclient.ClientConnectionManager#xmppStreamClosed to create and send STREAM_CLOSED, STREAM_FINISHED stanzas
tigase.server.xmppclient.StreamManagementIOProcessor#sendErrorsForQueuedPackets
-> tigase.server.xmppclient.ClientConnectionManager#processUndeliveredPacket to process undelivered stanzas
After creatingSTREAM_CLOSED, STREAM_FINISHED stanzas, they are started to process by calling addOutPacket however undelivered stanzas are started to process by calling processOutPacket.
Somehow, the first undelivered stanza processed before STREAM_CLOSED, STREAM_FINISHED stanzas in SessionManager. The first undelivered stanza includes delivery-error element that is processed by Message forwarder tigase.xmpp.impl.Message#preProcess and then tigase/xmpp/impl/C2SDeliveryErrorProcessor#preProcess filter stanza when it finds XMPPResourceConnection.
Describe the bug There is a race condition between
STREAM_CLOSED
,STREAM_FINISHED
command stanzas and processing undelivered stanzas.When the connection is closed
tigase.server.xmppclient.StreamManagementIOProcessor#serviceStopped
method is called.tigase.server.xmppclient.StreamManagementIOProcessor#serviceStopped
calls;tigase.server.xmppclient.ClientConnectionManager#serviceStopped
->tigase.server.xmppclient.ClientConnectionManager#xmppStreamClosed
to create and sendSTREAM_CLOSED
,STREAM_FINISHED
stanzastigase.server.xmppclient.StreamManagementIOProcessor#sendErrorsForQueuedPackets
->tigase.server.xmppclient.ClientConnectionManager#processUndeliveredPacket
to process undelivered stanzasAfter creating
STREAM_CLOSED
,STREAM_FINISHED
stanzas, they are started to process by callingaddOutPacket
however undelivered stanzas are started to process by callingprocessOutPacket
.Somehow, the first undelivered stanza processed before
STREAM_CLOSED
,STREAM_FINISHED
stanzas in SessionManager. The first undelivered stanza includesdelivery-error
element that is processed by Message forwardertigase.xmpp.impl.Message#preProcess
and thentigase/xmpp/impl/C2SDeliveryErrorProcessor#preProcess
filter stanza when it finds XMPPResourceConnection.To Reproduce Send bulk messages to the receiver. The receiver disconnects before not sending the acknowledgment to all of the stanzas
Impact Undelivered stanza processing is blocked by the Message forwarder and does not go through to offline messages. It causes the message lost.
[1;92m[2022-12-27 08:05:24:390][0;36m [FINEST ][0m [ in_20-sess-man ][1;34m SessionManager.processPacket() : [0mPacket blocked by: message, packetfrom=c2s@internal/10.10.10.10_5222_192.168.255.255_61068, to=sess-man@internal, DATA=<message from="d6ce@mydomain.com/5964a0422a5b938a" to="6711@mydomain.com" xmlns="jabber:client" type="chat" id="gPHAlLqtwVnAoAKaFJm2o6PxbAjjbj"><group id="HY0FD" xmlns="http://kontalk.org/extensions/message#group"><nick xmlns="http://jabber.org/protocol/nick">Nick-d6ce</nick><body>Message 13</body><active xmlns="http://jabber.org/protocol/chatstates"/></group><delay xmlns="urn:xmpp:delay" stamp="2022-12-27T08:05:22.599Z" from="mydomain.com"/><delivery-error stamp="1672128322599" xmlns="http://tigase.org/delivery-error"/></message>, SIZE=623, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=chat
Expected behavior We have to ensure
STREAM_CLOSED
,STREAM_FINISHED
stanzas are processed before the undelivered stanza.Screenshots NA
Details (please complete the following information):
Additional context tigase.log