Skip to content

Commit 5c87d01

Browse files
committed
fix(supervisor-middleware): configure HTTP/2 keepalive on middleware gRPC channel
Signed-off-by: Artem Lytvyn <[email protected]>
1 parent df69804 commit 5c87d01

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • crates/openshell-supervisor-middleware/src

‎crates/openshell-supervisor-middleware/src/remote.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use tonic::{Request, Response, Status};
1616
use crate::MIDDLEWARE_GRPC_MESSAGE_BYTES;
1717

1818
const CONNECT_TIMEOUT: Duration = Duration::from_secs(5);
19+
const HTTP2_KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(10);
20+
const HTTP2_KEEP_ALIVE_TIMEOUT: Duration = Duration::from_secs(20);
1921

2022
#[derive(Clone)]
2123
pub struct RemoteMiddlewareService {
@@ -30,7 +32,12 @@ impl RemoteMiddlewareService {
3032
format!(
3133
"middleware registration '{registration_name}' has an invalid grpc_endpoint"
3234
)
33-
})?;
35+
})?
36+
.http2_keep_alive_interval(HTTP2_KEEP_ALIVE_INTERVAL)
37+
.keep_alive_while_idle(true)
38+
.keep_alive_timeout(HTTP2_KEEP_ALIVE_TIMEOUT)
39+
.http2_adaptive_window(true);
40+
3441
if grpc_endpoint.starts_with("https://") {
3542
endpoint = endpoint
3643
.tls_config(ClientTlsConfig::new().with_enabled_roots())
@@ -39,6 +46,7 @@ impl RemoteMiddlewareService {
3946
format!("middleware registration '{registration_name}' could not configure TLS")
4047
})?;
4148
}
49+
4250
let channel = endpoint
4351
.connect_timeout(CONNECT_TIMEOUT)
4452
.connect()
@@ -49,6 +57,7 @@ impl RemoteMiddlewareService {
4957
"middleware registration '{registration_name}' could not connect to {grpc_endpoint}"
5058
)
5159
})?;
60+
5261
Ok(Self {
5362
client: SupervisorMiddlewareClient::new(channel)
5463
.max_decoding_message_size(MIDDLEWARE_GRPC_MESSAGE_BYTES)

0 commit comments

Comments
 (0)