Close oldest unactivated session at the session limit#1760
Merged
kevinherron merged 1 commit intoJun 2, 2026
Merged
Conversation
When MaxSessions was reached, SessionManager.createSession always threw Bad_TooManySessions. OPC UA Part 4, 5.7.2 requires that the server shall close the oldest Session that has not yet been activated before rejecting a new request, returning Bad_TooManySessions only when every existing Session has already been activated. Evict the oldest unactivated session (by connection time) instead. The limit check, eviction, and registration now run under a single lock and after request validation, so concurrent CreateSession requests cannot exceed MaxSessions and a request that later fails validation never evicts another client's pending session. ActivateSession's created-to-active move takes the same lock and rejects a session evicted mid-activation. Fixes eclipse-milo#1759 Signed-off-by: Jooyoung Jung <livinglikekrillin@gmail.com>
kevinherron
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the session limit (
MaxSessions) was reached,SessionManager.createSessionalways returned
Bad_TooManySessions. OPC UA Part 4, §5.7.2 requires that theserver shall close the oldest Session that has not yet been activated before
rejecting a new request, and return
Bad_TooManySessionsonly when every existingSession has already been activated.
This was raised in #1759 (from Discussion #1582), where the maintainer confirmed
no work was in progress and welcomed a PR.
Changes
instead of unconditionally throwing
Bad_TooManySessions.request validation, so concurrent
CreateSessionrequests cannot exceedMaxSessions, and a request that later fails validation never evicts anotherclient's pending session.
ActivateSession's created→active move takes the same lock and rejects a sessionthat was evicted mid-activation (
Bad_SessionIdInvalid).Tests
SessionEvictionTest: evicts the oldest unactivated session; still returnsBad_TooManySessionswhen all sessions are activated; never exceeds the limitunder a concurrent
CreateSessionburst.TestServer.create(OpcUaServerConfigLimits)overload to setMaxSessions.Fixes #1759
Developed with AI assistance (Anthropic Claude Opus 4.8); the human contributor
reviewed, verified, and tested all changes.