diff --git a/crates/torii/grpc/src/client.rs b/crates/torii/grpc/src/client.rs index 6499dde2dd..3cbd3cbe75 100644 --- a/crates/torii/grpc/src/client.rs +++ b/crates/torii/grpc/src/client.rs @@ -1,5 +1,6 @@ //! Client implementation for the gRPC service. use std::num::ParseIntError; +use std::time::Duration; use futures_util::stream::MapOk; use futures_util::{Stream, StreamExt, TryStreamExt}; @@ -50,8 +51,11 @@ pub struct WorldClient { impl WorldClient { #[cfg(not(target_arch = "wasm32"))] pub async fn new(dst: String, world_address: Felt) -> Result { - let endpoint = - Endpoint::from_shared(dst.clone()).map_err(|e| Error::Endpoint(e.to_string()))?; + const KEEPALIVE_TIME: u64 = 60; + + let endpoint = Endpoint::from_shared(dst.clone()) + .map_err(|e| Error::Endpoint(e.to_string()))? + .tcp_keepalive(Some(Duration::from_secs(KEEPALIVE_TIME))); let channel = endpoint.connect().await.map_err(Error::Transport)?; Ok(Self { _world_address: world_address,