aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahooinc.com>2023-09-11 17:03:04 +0200
committerBjørn Christian Seime <bjorncs@yahooinc.com>2023-09-11 17:19:52 +0200
commitb80ce12213ec7db116017ad4559306ebd5e4e86d (patch)
tree140cc32f57bc7ded013338b41cad2d5ed7fd9a20 /vespa-feed-client
parent560b31537c24086b7e5d8b97783c4fc2bf1db35b (diff)
Ensure connections are cycled regularly when using secure HTTP/2 tunnel
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java6
1 files changed, 5 insertions, 1 deletions
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);