This is an automated email from the ASF dual-hosted git repository.

Cole-Greer pushed a commit to branch HTTPClientPoC
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/HTTPClientPoC by this push:
     new 9b8ed167be Add response timeout to prevent indefinite client hang
9b8ed167be is described below

commit 9b8ed167be702e2ce30d79e0c9692bee965d6a0b
Author: Cole Greer <[email protected]>
AuthorDate: Fri May 8 15:05:33 2026 -0700

    Add response timeout to prevent indefinite client hang
    
    Add RequestConfig.responseTimeout (defaults to idleConnectionTimeout,
    or 180s if idle timeout is disabled) to the Apache HC async client.
    This is equivalent to the old Netty IdleStateHandler that would close
    the channel after prolonged inactivity.
    
    Without this, the client hangs forever if the server accepts a request
    (sends HTTP 200 chunked) but never sends response data (e.g., during
    uninterruptible Groovy compilation of oversized scripts).
---
 .../src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java  | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java 
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
index fc29c335e2..ec93dce4a9 100644
--- 
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
+++ 
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
@@ -22,6 +22,7 @@ import org.apache.commons.configuration2.Configuration;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.hc.client5.http.config.ConnectionConfig;
+import org.apache.hc.client5.http.config.RequestConfig;
 import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
 import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
 import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager;
@@ -880,7 +881,12 @@ public final class Cluster {
 
         final PoolingAsyncClientConnectionManager connManager = 
connManagerBuilder.build();
 
+        final RequestConfig requestConfig = RequestConfig.custom()
+                
.setResponseTimeout(Timeout.ofMilliseconds(builder.idleConnectionTimeoutMillis 
> 0 ? builder.idleConnectionTimeoutMillis : 180000))
+                .build();
+
         final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
+                .setDefaultRequestConfig(requestConfig)
                 .setIOReactorConfig(ioReactorConfig)
                 .setConnectionManager(connManager)
                 .build();

Reply via email to