Skip to content

OF-3459: Measure the detach timeout from the moment a session detached - #3559

Merged
guusdk merged 1 commit into
igniterealtime:mainfrom
guusdk:OF-3459
Nov 18, 2026
Merged

guusdk merged 1 commit into
igniterealtime:mainfrom
guusdk:OF-3459

Conversation

@guusdk

@guusdk guusdk commented Nov 11, 2026

Copy link
Copy Markdown
Member

A client session that uses Stream Management is kept for a while after its connection breaks, so that the client can resume its stream: for xmpp.session.detach.timeout, 10 minutes by default, which Openfire also announces to the client in the 'max' attribute of . The task that ends detached sessions measured that time from the last stanza that the session sent or received, not from the moment at which it was detached. A session that had been quiet for longer than its timeout before its connection broke was therefore ended at the first run of that task after it was detached, within about a minute with the default settings, before the client could resume it.

A session now records the moment at which it is detached, and the timeout is measured from that moment, or from the last activity of the session when that is later. A session that is resumed and later detached again gets the full timeout from its second detach. A session that is registered as detached without being detached has no such moment, or only that of an earlier detach, and is measured from its last activity.

A client whose connection broke after a quiet period therefore stays available to its contacts for up to the detach timeout, as a busy one already did. The last activity of a session, as shown in the admin console, keeps its meaning. Termination delegates, which decide for themselves when a detached session ends, are not affected.

A client session that uses Stream Management is kept for a while after its connection breaks, so that the client can resume its stream: for xmpp.session.detach.timeout, 10 minutes by default, which Openfire also announces to the client in the 'max' attribute of <enabled/>. The task that ends detached sessions measured that time from the last stanza that the session sent or received, not from the moment at which it was detached. A session that had been quiet for longer than its timeout before its connection broke was therefore ended at the first run of that task after it was detached, within about a minute with the default settings, before the client could resume it.

A session now records the moment at which it is detached, and the timeout is measured from that moment, or from the last activity of the session when that is later. A session that is resumed and later detached again gets the full timeout from its second detach. A session that is registered as detached without being detached has no such moment, or only that of an earlier detach, and is measured from its last activity.

A client whose connection broke after a quiet period therefore stays available to its contacts for up to the detach timeout, as a busy one already did. The last activity of a session, as shown in the admin console, keeps its meaning. Termination delegates, which decide for themselves when a detached session ends, are not affected.
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

LocalSession now records its most recent detachment time and exposes it through getLastDetachedDate(). DetachedCleanupTask calculates elapsed time from the later of that timestamp and last activity, falling back to last activity when the timestamp is missing or earlier. The task terminates sessions only when elapsed time exceeds the configured timeout. Tests cover these timing cases.

Possibly related PRs

Suggested reviewers: fishbowler, viv

Merge Risk: Minimal · up to e901a

This change measures the detached-session timeout from the detach time, or from later activity, so quiet sessions are no longer ended before the client can resume them. No concrete merge-blocking risk was found in the reviewed changes.

Pre-merge checks: Passed 3

Check name Status Explanation
Description check Passed The description directly explains the detached-session timeout changes, detach timestamp tracking, resumed-session behavior, fallback to last activity, and unchanged termination delegates.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 01837572-380e-459c-a478-662c10480132
Commits

Reviewing files that changed from the base of the PR and between 5cae384 and e901a72.

Files selected for processing: 3

  • xmppserver/src/main/java/org/jivesoftware/openfire/SessionManager.java
  • xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalSession.java
  • xmppserver/src/test/java/org/jivesoftware/openfire/SessionManagerDetachTimeoutTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@guusdk
guusdk requested a review from viv November 11, 2026 14:37

@akrherz akrherz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reads sensible to me.

@bobatron bobatron left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OF-3459: passed test at e901a72ff, against main at 5cae384d2

Step Result
Delivered tests 8/8 pass
Mutation testing 9/9 checks detected; every test fails under at least one mutation
Regression run (full xmppserver suite) 3010 run, 0 failures, 3 skipped (disabled in the codebase)
Independent conditions (running server, against main at 5cae384) 24/24 as expected; 10 differ from main, all intended

Independent conditions:

  • Quiet session, connection broken: resumable for the full detach timeout after the break, over STARTTLS, direct TLS, WebSocket and SASL2 inline resume; on main it was already gone within one cleanup run. Also with the default 10-minute timeout (quiet for 11 minutes, resumed 2 minutes after the break).
  • Still ends on time: a session resumed after the timeout fails, quiet or busy, and the account's other resources see it go offline at the timeout, not within seconds.
  • Detached again after a resumption: measured from the second break.
  • Unchanged: stanzas sent to a detached session do not extend it; a properly closed stream and an idle connection closed by the server are not kept; max matches the timeout, and is absent when it is disabled.

Mutation testing:

  • never() checks: each of the four fails on its own when sessions are ended early.

Coverage: adequate as delivered. The change is logic inside the cleanup task, and the unit tests cover each branch of it: measured from the detach, from later activity, with no detach moment, and after a second detach. A test at a higher level would have to wait out a real detach timeout, which adds little over the unit tests.

@guusdk
guusdk merged commit b83c809 into igniterealtime:main Nov 18, 2026
90 of 91 checks passed
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.

4 participants