From b80ce12213ec7db116017ad4559306ebd5e4e86d Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Mon, 11 Sep 2023 17:03:04 +0200 Subject: Ensure connections are cycled regularly when using secure HTTP/2 tunnel --- .../src/main/java/ai/vespa/feed/client/impl/JettyCluster.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'vespa-feed-client') diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java index 3a5c98ca27c..e4e6fbe752e 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java @@ -140,7 +140,9 @@ class JettyCluster implements Cluster { connector.setExecutor(new QueuedThreadPool(threads)); connector.setSslContextFactory(clientSslCtxFactory); connector.setIdleTimeout(IDLE_TIMEOUT); - connector.setConnectTimeout(Duration.ofSeconds(30)); + boolean secureProxy = b.proxy != null && b.proxy.getScheme().equals("https"); + // Increase connect timeout for secure HTTP/2 proxy + connector.setConnectTimeout(Duration.ofSeconds(secureProxy ? 120 : 30)); HTTP2Client h2Client = new HTTP2Client(connector); h2Client.setMaxConcurrentPushedStreams(b.maxStreamsPerConnection); // Set the HTTP/2 flow control windows very large to cause TCP congestion instead of HTTP/2 flow control congestion. @@ -156,6 +158,8 @@ class JettyCluster implements Cluster { MultiplexConnectionPool pool = new MultiplexConnectionPool( dest, Pool.StrategyType.RANDOM, connectionsPerEndpoint, false, dest, Integer.MAX_VALUE); pool.preCreateConnections(connectionsPerEndpoint); + if (secureProxy) pool.setMaxDuration(Duration.ofMinutes(1).toMillis()); + else pool.setMaximizeConnections(true); return pool; }); HttpClient httpClient = new HttpClient(transport); -- cgit v1.2.3