Skip to content

OF-3176: Fix stanza loss during outgoing S2S session teardown#3232

Open
guusdk wants to merge 1 commit intoigniterealtime:mainfrom
guusdk:OF-3176_Schedule-dont-drop-s2s-stanza-after-async-connection-closure
Open

OF-3176: Fix stanza loss during outgoing S2S session teardown#3232
guusdk wants to merge 1 commit intoigniterealtime:mainfrom
guusdk:OF-3176_Schedule-dont-drop-s2s-stanza-after-async-connection-closure

Conversation

@guusdk
Copy link
Copy Markdown
Member

@guusdk guusdk commented Mar 26, 2026

When an outgoing server-to-server (S2S) connection closes, the connection is marked closed immediately, but route removal from the routing table happens asynchronously during teardown. This creates a short race window where routing can still send stanzas to a closing session, which then sees a closed connection and drops the stanza.

This change fixes that behavior by waiting for teardown to fully complete before re-routing a stanza that reached a closed outgoing session. Waiting for close completion ensures stale route cleanup has finished, after which normal routing can use an existing replacement session or create a new one.

A new system property, xmpp.server.session.redelivery-timeout (default: 30 seconds), controls how long Openfire waits for teardown completion before returning an error to the sender.

Copilot AI review requested due to automatic review settings March 26, 2026 21:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses OF-3176 by preventing stanza loss when an outgoing S2S session is closing: instead of immediately bouncing/dropping on a closed connection while route removal is still in-flight, it waits for teardown completion and then re-routes the stanza (with a configurable timeout).

Changes:

  • Add a new dynamic system property (xmpp.server.session.redelivery-timeout, default 30s) to bound how long to wait for outgoing-session teardown completion before abandoning re-delivery.
  • Update outgoing S2S stanza delivery logic to await Connection#getCloseFuture() completion before re-routing stanzas that hit a closed connection, while avoiding “double-bounce” for error stanzas.
  • Add i18n strings (EN + NL) for the new system property description.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalOutgoingServerSession.java Adds the redelivery-timeout property and re-delivery logic that waits for teardown completion before re-routing.
i18n/src/main/resources/openfire_i18n.properties Adds English description for the new system property.
i18n/src/main/resources/openfire_i18n_nl.properties Adds Dutch description for the new system property.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

When an outgoing server-to-server (S2S) connection closes, the connection is marked closed immediately, but route removal from the routing table happens asynchronously during teardown. This creates a short race window where routing can still send stanzas to a closing session, which then sees a closed connection and drops the stanza.

This change fixes that behavior by waiting for teardown to fully complete before re-routing a stanza that reached a closed outgoing session. Waiting for close completion ensures stale route cleanup has finished, after which normal routing can use an existing replacement session or create a new one.

A new system property, xmpp.server.session.redelivery-timeout (default: 30 seconds), controls how long Openfire waits for teardown completion before returning an error to the sender.
@guusdk guusdk force-pushed the OF-3176_Schedule-dont-drop-s2s-stanza-after-async-connection-closure branch from 17ff22b to ad77029 Compare March 26, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants