Skip to content

Commit b565367

Browse files
authored
Add gRPC keepalive configuration to detect stale connections (#4908)
## Motivation 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 We can reproduce this on the testnet. We can deploy to `conway-test` just to make sure it doesn't break anything (run e2e tests, for example), and then deploy to `testnet-conway`.
1 parent 931e814 commit b565367

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)