From 358fb8e58abbc3b4d968b64ca26a0354dbc1f5d7 Mon Sep 17 00:00:00 2001 From: Ravi Khadiwala Date: Fri, 6 Nov 2026 14:07:28 -0600 Subject: [PATCH] Switch all-idle timeout to read-idle timeout idle-timeouts now fire when we haven't read anything from the client after the configured timeout. This ensures timeouts still fire if our outbound writes are just being buffered somewhere. Also, update the default timeout to 1 minute --- .../textsecuregcm/configuration/GrpcConfiguration.java | 6 ++++-- .../textsecuregcm/grpc/net/OmnibusH2Server.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/GrpcConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/GrpcConfiguration.java index 5c72f25ba..80f905e13 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/GrpcConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/GrpcConfiguration.java @@ -14,7 +14,9 @@ import java.time.Duration; /// @param port The port to bind the omnibus server to /// @param websocketAddress The address of a listening websocket server for handling legacy requests /// @param websocketPort The port of a listening websocket server for handling legacy requests -/// @param idleTimeout The duration after which an idle connection may be disconnected +/// @param idleTimeout The duration after which a connection the client has not written to may be disconnected. +/// Clients are expected to send some periodic write traffic (application-level or h2-level +/// pings) to keep otherwise idle connections open /// @param h2c If true, listen for plaintext h2c with prior-knowledge /// @param sslProvider The TLS implementation used to terminate TLS. Defaults to `OPENSSL`. public record GrpcConfiguration( @@ -34,7 +36,7 @@ public record GrpcConfiguration( websocketAddress = "localhost"; } if (idleTimeout == null) { - idleTimeout = Duration.ofMinutes(5); + idleTimeout = Duration.ofSeconds(60); } if (sslProvider == null) { sslProvider = SslProvider.OPENSSL; diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/net/OmnibusH2Server.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/net/OmnibusH2Server.java index 12da6ca31..9e51dcec0 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/net/OmnibusH2Server.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/net/OmnibusH2Server.java @@ -80,7 +80,7 @@ public class OmnibusH2Server implements Managed { /// @param bindAddress The address the server should listen on /// @param router How the server should select backends based on request paths /// @param configurationSupplier Dynamic configuration supplier - /// @param idleTimeout How long to wait before terminating idle TCP connections + /// @param idleTimeout How long to wait since the last data was received from the client before terminating TCP connections public OmnibusH2Server( final @Nullable Mapping sslContextBySni, final EventLoopGroup nioEventLoopGroup, @@ -109,7 +109,7 @@ public class OmnibusH2Server implements Managed { .childHandler(new ChannelInitializer() { @Override protected void initChannel(final SocketChannel ch) { - ch.pipeline().addLast(new IdleStateHandler(0, 0, idleTimeout.toMillis(), TimeUnit.MILLISECONDS)); + ch.pipeline().addLast(new IdleStateHandler(idleTimeout.toMillis(), 0, 0, TimeUnit.MILLISECONDS)); ch.pipeline().addLast(new SimpleUserEventChannelHandler() { @Override protected void eventReceived(final ChannelHandlerContext ctx, final IdleStateEvent evt) {