Skip to content

Conversation

@marregui
Copy link
Contributor

card: https://hivemq.kanbanize.com/ctrl_board/57/cards/38362/details/

  • Removed hardcoded KEEP_ALIVE_TIMEOUT_MS = 30_000
  • Added a new public method getKeepAliveTimeoutMs() that computes the timeout dynamically using the formula:
    keepAliveIntervalMs × (keepAliveFailuresAllowed + 1) + 5000ms (safety margin)
  • Updated isKeepAliveHealthy() to use the dynamically computed timeout

Formula Explanation

With default ConnectionOptions:

  • keepAliveIntervalMs = 10,000ms (10 seconds)
  • keepAliveFailuresAllowed = 3
  • Safety margin = 5,000ms

Result: 10,000 × (3 + 1) + 5,000 = 45,000ms (45 seconds)

This is more appropriate than the previous hardcoded 30 seconds because:

  • The OPC UA client allows 3 failures before considering the connection dead
  • With a 10-second keep-alive interval, worst case is 30 seconds before failure detection
  • The extra interval + safety margin prevents false positives

@marregui marregui self-assigned this Nov 27, 2025
@cla-bot cla-bot bot added the cla-signed label Nov 27, 2025
Copy link
Member

@caoccao caoccao left a comment

Choose a reason for hiding this comment

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

LGTM

…veIntervalMs() * (connOpts.keepAliveFailuresAllowed() + 1) + 5_000L instead of the hardcoded 30 seconds, which exactly matched by chance keepAliveIntervalMs * keepAliveFailuresAllowed
@marregui marregui force-pushed the bugfix/38362_keepAliveTimeout branch from 9861544 to 20034c5 Compare December 10, 2025 09:22
@marregui marregui requested a review from caoccao December 10, 2025 09:22
Copy link
Member

@caoccao caoccao left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants