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

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 598b2ab148 fix(httpclient): enable keep-alive by default (#7179)
598b2ab148 is described below

commit 598b2ab14859b6e2f985a7715a2c918c29dee9ad
Author: Liming Deng <[email protected]>
AuthorDate: Tue Oct 20 14:31:12 2026 +0800

    fix(httpclient): enable keep-alive by default (#7179)
    
    * fix(httpclient): enable keep-alive by default
    
    * docs(httpclient): explain keep-alive default and reset escape hatch
---
 RELEASE-NOTES.md                                                 | 9 +++++++++
 .../shenyu/plugin/httpclient/config/HttpClientProperties.java    | 4 ++--
 .../shenyu/plugin/httpclient/HttpClientPropertiesTest.java       | 1 +
 .../springboot/starter/plugin/httpclient/HttpClientFactory.java  | 4 ++--
 4 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 545c02c38f..44f1c31e75 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -28,6 +28,15 @@
 
 ### Behavior Changes
 
+- `shenyu.httpclient.keepAlive` now defaults to `true`, enabling persistent
+  upstream connections and reducing connection setup overhead. It previously
+  defaulted to `false` as a workaround for stale pooled connections being reset
+  by the peer (Reactor Netty issue #388).
+  Configure `shenyu.httpclient.pool.maxIdleTime` below the upstream or load 
balancer idle timeout
+  when using a fixed connection pool. If connection resets persist, restore
+  the previous behavior with `shenyu.httpclient.keepAlive=false`.
+  For a fixed pool, set `shenyu.httpclient.pool.maxConnections` explicitly to
+  size the connection limit for the deployment; the default follows Reactor 
Netty.
 - CORS origin patterns are compiled when the gateway starts. An invalid
   `shenyu.cross.allowed-origin.origin-regex` now fails startup with
   `PatternSyntaxException`, rather than failing the first matching request.
diff --git 
a/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/config/HttpClientProperties.java
 
b/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/config/HttpClientProperties.java
index dfbe4db247..8bbf78eb37 100644
--- 
a/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/config/HttpClientProperties.java
+++ 
b/shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/config/HttpClientProperties.java
@@ -115,9 +115,9 @@ public class HttpClientProperties {
     private boolean wiretap;
 
     /**
-     * set to false, fix java.io.IOException: Connection reset by peer, see 
https://github.com/reactor/reactor-netty/issues/388.
+     * Whether persistent HTTP connections are enabled.
      */
-    private boolean keepAlive;
+    private boolean keepAlive = true;
 
     /**
      * body max memory size, unit mb.
diff --git 
a/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/HttpClientPropertiesTest.java
 
b/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/HttpClientPropertiesTest.java
index 90ee5a9cd1..1b079e8e84 100644
--- 
a/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/HttpClientPropertiesTest.java
+++ 
b/shenyu-plugin/shenyu-plugin-httpclient/src/test/java/org/apache/shenyu/plugin/httpclient/HttpClientPropertiesTest.java
@@ -156,6 +156,7 @@ public class HttpClientPropertiesTest {
     @Test
     public void httpClientPropertiesTest() {
         HttpClientProperties httpClientProperties = new HttpClientProperties();
+        Assertions.assertTrue(httpClientProperties.isKeepAlive());
         httpClientProperties.setAllIdleTime(1);
         httpClientProperties.setConnectTimeout(1);
         httpClientProperties.setKeepAlive(true);
diff --git 
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientFactory.java
 
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientFactory.java
index 2243538814..afcfb3c8c4 100644
--- 
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientFactory.java
+++ 
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientFactory.java
@@ -143,8 +143,8 @@ public class HttpClientFactory extends 
AbstractFactoryBean<HttpClient> {
         if (properties.isWiretap()) {
             httpClient = httpClient.wiretap(true);
         }
-        // set to false, fix java.io.IOException: Connection reset by peer
-        // see https://github.com/reactor/reactor-netty/issues/388
+        // Reuse connections by default. Tune the fixed pool's maxIdleTime 
below the upstream idle limit;
+        // keepAlive=false remains an escape hatch for stale-connection resets 
(reactor-netty#388).
         return httpClient.keepAlive(properties.isKeepAlive());
     }
 

Reply via email to