-
Enhancement
-
Resolution: Fixed
-
P4
-
17
-
b25
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
This is similar to https://bugs.openjdk.org/browse/JDK-8203701, although 8203701 discuses size of a pool.
Although often it is necessary to close idle HTTP/2 connections before server sends GOAWAY packet, because certain Cloud Load Balancers can close idle TCP connections silently.
AWS : 350 seconds
Azure Load Balancer : 4 minutes by default.
If server chooses to send GOAWAY later than LB TCP idle timeout, HttpClient throws "Connection Reset by Peer" on a next attempt of connection reuse
An example code
public class Test {
private static final HttpClient CLIENT = HttpClient.newBuilder().version( HttpClient.Version.HTTP_2 ).build();
public static void main( String[] args ) throws Exception {
final HttpRequest request = HttpRequest.newBuilder().uri( URI.create( "https://example.com/" ) ).build(); // example.com normally sends GOAWAY in 180 seconds
System.out.println( CLIENT.send( request, HttpResponse.BodyHandlers.ofString() ).body() );
Thread.sleep( 200 * 1000 ); // Assuming LB closes TCP connection in 120 seconds
System.out.println( CLIENT.send( request, HttpResponse.BodyHandlers.ofString() ).body() ); // Throws Connection reset by peer
}
}
This is similar to https://bugs.openjdk.org/browse/JDK-8203701, although 8203701 discuses size of a pool.
Although often it is necessary to close idle HTTP/2 connections before server sends GOAWAY packet, because certain Cloud Load Balancers can close idle TCP connections silently.
AWS : 350 seconds
Azure Load Balancer : 4 minutes by default.
If server chooses to send GOAWAY later than LB TCP idle timeout, HttpClient throws "Connection Reset by Peer" on a next attempt of connection reuse
An example code
public class Test {
private static final HttpClient CLIENT = HttpClient.newBuilder().version( HttpClient.Version.HTTP_2 ).build();
public static void main( String[] args ) throws Exception {
final HttpRequest request = HttpRequest.newBuilder().uri( URI.create( "https://example.com/" ) ).build(); // example.com normally sends GOAWAY in 180 seconds
System.out.println( CLIENT.send( request, HttpResponse.BodyHandlers.ofString() ).body() );
Thread.sleep( 200 * 1000 ); // Assuming LB closes TCP connection in 120 seconds
System.out.println( CLIENT.send( request, HttpResponse.BodyHandlers.ofString() ).body() ); // Throws Connection reset by peer
}
}
- csr for
-
JDK-8295649 Add a means to close idle connections in HTTP/2 connection pool
- Closed
- relates to
-
JDK-8312433 HttpClient request fails due to connection being considered idle and closed
- Closed