diff --git a/src/grpc/mod.rs b/src/grpc/mod.rs index f407ca7..4aa4d85 100644 --- a/src/grpc/mod.rs +++ b/src/grpc/mod.rs @@ -12,6 +12,7 @@ pub use proto::code_agent_server::{CodeAgent, CodeAgentServer}; pub use proto::*; use std::sync::Arc; +use std::time::Duration; use tonic::transport::Server; use tracing::{error, info}; @@ -57,7 +58,9 @@ pub async fn start_server(state: Arc) -> anyhow::Result<()> { let svc = service::CodeAgentService::new(state); - let mut builder = Server::builder(); + let mut builder = Server::builder() + .http2_keepalive_interval(Some(Duration::from_secs(15))) + .http2_keepalive_timeout(Some(Duration::from_secs(5))); if dev_mode { info!(%addr, "Starting gRPC server (dev mode — no auth)"); diff --git a/src/grpc/service.rs b/src/grpc/service.rs index c79cc41..399a0db 100644 --- a/src/grpc/service.rs +++ b/src/grpc/service.rs @@ -303,6 +303,13 @@ async fn run_session( Some(client_message::Payload::Start(_)) => { warn!("Received duplicate StartSession — ignoring"); } + Some(client_message::Payload::Ping(p)) => { + let _ = tx.send(Ok(ServerMessage { + payload: Some(server_message::Payload::Pong(Pong { + timestamp: p.timestamp, + })), + })).await; + } // ToolResult and Approval are handled by the orchestrator bridge _ => continue, }