[improve] modify ssh client common config #2403
Merged
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.
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
Add or update API