[BUG] Openfire looses messages when multiple senders send messages to the same receiver that looses connection

Hi all,

when multiple senders send messages to the same receiver in parallel it can happen that Openfire losses messages and do not call backup deliverer when receiver looses connection in the meantime.

The problem is in org.jivesoftware.openfire.session.LocalClientSession.deliver(Packet). There it gets checked if the connection is closed. If this is the case then the packet is dropped silently. You can reproduce this with breakpoints. Example sequence to reproduce:

  • sender2 is in org.jivesoftware.openfire.session.LocalClientSession.deliver(Packet) before the if statement

  • sender1 thread is in org.jivesoftware.openfire.nio.NIOConnection.deliver(Packet)

  • sender1 thread catches IOException and closes connection

  • sender2 now evaluates if statement and silently drops packet

The expected behavior myself was that Openfire uses the offline cache strategy for this packet now.

I do not know the Openfire code in detail, but I think the org.jivesoftware.openfire.Connection.isClosed() check can be simply removed. org.jivesoftware.openfire.nio.NIOConnection.deliver(Packet) and org.jivesoftware.openfire.net.SocketConnection.deliver(Packet) do the check again anyway and pass the packet do backup delivery if connection is closed.

Thanks a lot

Daniel

Thanks for the excellent report, opened OF-855 to track it.

Thanks Daniel.

Do you think this is the same bug: OF-486 ?

I also thought about this before I opened the Bug. But I don’t think they are related to each other. OF-486 reads like the receivers are offline already while the messages get sent. The bug reported by me assumes that the receivers go offline while the messages get sent. But who knows… .