Skip to content

Commit 0a0ba6b

Browse files
authored
Add gRPC keepalive configuration to detect stale connections (#4918)
## Motivation This is a forward port of #4908. Seems that `connect_lazy` doesn't reconnect automatically unless we specify a keep alive hyperium/tonic#1254 There's some evidence we might be seeing that on the testnet on the proxy, as the user from the issue is seeing the same errors we're seeing. ## Proposal Add keep alives so that they can expire and `connect_lazy` can reconnect automatically. ## Test Plan This has been deployed to `testnet-conway` ## Release Plan - These changes have already been backported to the latest `testnet` branch
1 parent 07b454d commit 0a0ba6b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

linera-rpc/src/grpc/transport.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ cfg_if::cfg_if! {
3434
options: &Options,
3535
) -> Result<Channel, Error> {
3636
let mut endpoint = tonic::transport::Endpoint::from_shared(address)?
37-
.tls_config(tonic::transport::channel::ClientTlsConfig::default().with_webpki_roots())?;
37+
.tls_config(tonic::transport::channel::ClientTlsConfig::default().with_webpki_roots())?
38+
.tcp_keepalive(Some(std::time::Duration::from_secs(60)))
39+
.http2_keep_alive_interval(std::time::Duration::from_secs(30))
40+
.keep_alive_timeout(std::time::Duration::from_secs(10))
41+
.keep_alive_while_idle(true);
3842

3943
if let Some(timeout) = options.connect_timeout {
4044
endpoint = endpoint.connect_timeout(timeout);

0 commit comments

Comments
 (0)