Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve] modify ssh client common config #2403

Merged
merged 6 commits into from
Jul 29, 2024

Conversation

Aias00
Copy link
Contributor

@Aias00 Aias00 commented Jul 29, 2024

What's changed?

modify ssh client common properties. Change HEARTBEAT_REPLY_WAIT to HEARTBEAT_NO_REPLY_MAX
see issue #2397

HEARTBEAT_NO_REPLY_MAX property:
The meaning of HEARTBEAT_NO_REPLY_MAX:
This property defines the maximum number of consecutive heartbeat responses that can be lost before the SSH client considers the connection to be disconnected.
Specific scenario example:
Let's assume we have the following configuration:

HEARTBEAT_INTERVAL is set to 10 seconds (10,000 milliseconds)
HEARTBEAT_NO_REPLY_MAX is set to 3

Scenario description:

The SSH client sends a heartbeat request to the server every 10 seconds.
Under normal circumstances:

The client sends a heartbeat
The server responds to the heartbeat
The connection is considered active

Now, let's assume some network issues occur:

0 seconds: The client sends the first heartbeat, no response received
10 seconds: The client sends the second heartbeat, still no response
20 seconds: The client sends the third heartbeat, again no response
30 seconds: The client prepares to send the fourth heartbeat

At this point, because there have been 3 consecutive heartbeats without a response, reaching the HEARTBEAT_NO_REPLY_MAX value:

The SSH client will consider the connection to be disconnected
The client may attempt to re-establish the connection or notify the application layer that the connection has been lost

If the network recovers to normal after sending the third heartbeat:

The server responds to the third heartbeat
The counter will be reset
The connection continues to remain active

The benefits of this mechanism are:

It can promptly detect network issues or server unresponsiveness.
It provides a degree of fault tolerance, not immediately disconnecting due to occasional network jitters.
Parameters can be adjusted based on network environment and application requirements to balance quick response and connection stability.

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

@Aias00
Copy link
Contributor Author

Aias00 commented Jul 29, 2024

set the HEARTBEAT_NO_REPLY_MAX to 30 now, means that : The SSH client will consider the connection to be disconnected if 30 consecutive heartbeats without a response

Copy link
Contributor

@tomsun28 tomsun28 left a comment

Choose a reason for hiding this comment

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

lgtm. max hearbeat timeout is CoreModuleProperties.HEARTBEAT_INTERVAL * CoreModuleProperties.HEARTBEAT_NO_REPLY_MAX -> 60s

@tomsun28 tomsun28 merged commit f5e88db into apache:master Jul 29, 2024
3 checks passed
@Aias00 Aias00 deleted the feature/modify_ssh_prop branch July 29, 2024 14:59
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.

[Task] <java ssh connect prop CoreModuleProperties HEARTBEAT_REPLY_WAIT to HEARTBEAT_NO_REPLY_MAX >
2 participants