Skip to content

Commit

Permalink
set ServerAliveInterval
Browse files Browse the repository at this point in the history
Connectors may not necessarily establish a connection with any kind of
client-side keep alive mechanism, and if SSH servers disconnect clients after a
period of inactivity this will cause the network tunnel to fail. Setting the
ServerAliveInterval should prevent that by causing our SSH client connection to
send period keepalive messages.
  • Loading branch information
williamhbaker committed Jul 1, 2024
1 parent a823071 commit ccaf43a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sshforwarding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ impl NetworkTunnel for SshForwarding {
// Ask the client to time out after 5 seconds
"-o".to_string(),
"ConnectTimeout=5".to_string(),
// Send period keepalive messages to the server to keep the
// connection from being closed due to inactivity.
"-o".to_string(),
"ServerAliveInterval=30".to_string(),
// Pass the private key
"-i".to_string(),
self.config.private_key.clone(),
Expand Down Expand Up @@ -149,7 +153,7 @@ impl NetworkTunnel for SshForwarding {
// InvalidInput means the process has already exited, in which case
// we do not need to cleanup the process
Err(e) if e.kind() == ErrorKind::InvalidInput => Ok(()),
a => a
a => a,
}?;
}

Expand Down

0 comments on commit ccaf43a

Please sign in to comment.