Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.0: WebClient HTTP keep-alive support appears to be broken #8077

Closed
barchetta opened this issue Nov 27, 2023 · 2 comments · Fixed by #8101
Closed

4.0.0: WebClient HTTP keep-alive support appears to be broken #8077

barchetta opened this issue Nov 27, 2023 · 2 comments · Fixed by #8101
Assignees
Labels
4.x Version 4.x bug Something isn't working must-have P1 webclient
Milestone

Comments

@barchetta
Copy link
Member

barchetta commented Nov 27, 2023

Environment Details

  • Helidon Version: 4.0.0 and 4.0.1
  • Helidon SE
  • JDK version: java 21.0.1 2023-10-17 LTS
  • OS: MacOS

Problem Description

The Helidon 4 WebClient HTTP keep-alive support appears to be broken. Even with keepAlive(true) the client does not reuse connections.

Steps to reproduce

See the attached test case: client.zip

This is based on the stand-alone webclient example that has been modified to set keepAlive(true) and to perform 10 GET requests sequentially. After the test is run (see README) netstat shows 10 connections in TIME_WAIT instead of one:

tcp4       0      0  127.0.0.1.56044        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56045        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56046        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56047        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56048        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56049        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56050        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56051        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56052        127.0.0.1.8080         TIME_WAIT
tcp4       0      0  127.0.0.1.56053        127.0.0.1.8080         TIME_WAIT
@barchetta barchetta added bug Something isn't working webclient 4.x Version 4.x labels Nov 27, 2023
@barchetta barchetta added this to the 4.0.2 milestone Nov 27, 2023
@barchetta
Copy link
Member Author

barchetta commented Nov 27, 2023

@romain-grecourt came up with this patch and appears to fix the issue. But it needs further review for correctness:

diff --git a/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1ClientResponseImpl.java b/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1ClientResponseImpl.java
index 16d4edc47b..3af52f6187 100644
--- a/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1ClientResponseImpl.java
+++ b/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1ClientResponseImpl.java
@@ -160,6 +160,8 @@ class Http1ClientResponseImpl implements Http1ClientResponse {
             try {
                 if (headers().contains(HeaderValues.CONNECTION_CLOSE)) {
                     connection.closeResource();
+                } else if (headers().contains(HeaderValues.CONNECTION_KEEP_ALIVE)) {
+                    connection.releaseResource();
                 } else {
                     if (entityLength == 0) {
                         connection.releaseResource();

@barchetta barchetta changed the title 4.0.1: WebClient HTTP keep-alive support appears to be broken 4.0.0: WebClient HTTP keep-alive support appears to be broken Nov 27, 2023
@barchetta barchetta added the P2 label Nov 27, 2023
@AshwinPrabhuB
Copy link

I had seen this in H3 but failed to report it since I found the Ning HTTP client to meet all our requirements out of the box. Consider backporting this to H3 as well

@barchetta barchetta added P1 and removed P2 labels Dec 4, 2023
danielkec added a commit to danielkec/helidon that referenced this issue Dec 4, 2023
danielkec added a commit to danielkec/helidon that referenced this issue Dec 4, 2023
danielkec added a commit to danielkec/helidon that referenced this issue Dec 5, 2023
danielkec added a commit to danielkec/helidon that referenced this issue Dec 5, 2023
danielkec added a commit to danielkec/helidon that referenced this issue Dec 7, 2023
danielkec added a commit that referenced this issue Dec 8, 2023
@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to Closed in Backlog Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x bug Something isn't working must-have P1 webclient
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants