Skip to content

Commit 95ddb3d

Browse files
committed
fix(mmserver): use QUIC PING frames to keep clients alive
This fixes a bug where a client would be kicked before its own timeout for a long-running operation like LaunchSession. By only sending keepalives if the client has open streams, we enforce that clients are still around, but let them time out if they're not doing anything.
1 parent a840c2b commit 95ddb3d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

mm-server/src/server.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ impl Server {
117117
};
118118

119119
config.set_application_protos(&[protocol::ALPN_PROTOCOL_VERSION])?;
120-
config.set_max_idle_timeout(10_000);
121120
config.set_initial_max_data(65536);
122121
config.set_initial_max_stream_data_bidi_remote(65536);
123122
config.set_initial_max_stream_data_bidi_local(65536);
@@ -127,6 +126,11 @@ impl Server {
127126
config.enable_dgram(true, 0, 1024 * 1024);
128127
config.enable_early_data();
129128

129+
// Set the idle timeout to 10s. If any streams are active, we send
130+
// ack-eliciting frames so that we don't accidentally kill a client
131+
// that's in the middle of something slow (like launching a session).
132+
config.set_max_idle_timeout(10_000);
133+
130134
// Storage for packets that would have blocked on sending.
131135
let outgoing_packets = VecDeque::new();
132136

@@ -418,6 +422,13 @@ impl Server {
418422
let span = trace_span!("gather_send", conn_id = ?client.conn_id);
419423
let _guard = span.enter();
420424

425+
// Generate ack-eliciting keepalives for any clients with open
426+
// streams. Clients with no open streams are allowed to time
427+
// out.
428+
if !client.in_flight.is_empty() {
429+
client.conn.send_ack_eliciting()?;
430+
}
431+
421432
loop {
422433
let start = off;
423434
self.scratch.resize(off + MAX_QUIC_PACKET_SIZE, 0);

0 commit comments

Comments
 (0)