Skip to content

HTTP/2 Client connection timeout does not work #13962

@jacob-pro

Description

@jacob-pro

Jetty version(s)
12.1.3

Jetty Environment
N/A

HTTP version
HTTP/2

Java version/vendor (use: java -version)
JDK 21

OS type/version
Linux

Description

The connection timeout does not seem to work for the HTTP/2 client.

How to reproduce?

The below code runs indefinitely without any timeout:

    public static void main(String[] args) throws Exception {
        ServerSocket serverTcpSocket = new ServerSocket(0);  // This socket will be unresponsive

        ClientConnector clientConnector = new ClientConnector();
        ClientConnectionFactory.Info http1 = HttpClientConnectionFactory.HTTP11;
        ClientConnectionFactory.Info http2 = new ClientConnectionFactoryOverHTTP2.HTTP2(new HTTP2Client(clientConnector));
        HttpClient httpClient = new HttpClient(new HttpClientTransportDynamic(clientConnector, http1, http2));
        httpClient.setConnectTimeout(1000);
        httpClient.setIdleTimeout(1000);
        httpClient.start();

        try {
            System.out.println("Attempting to connect");
            httpClient.GET(URI.create("https://localhost:" + serverTcpSocket.getLocalPort())).getContent();
        } catch (Exception e) {
            System.out.println("Connection failed " + e);
        }
    }

If I comment out http2, and just use the http1 connector, then it works as expected:

Attempting to connect
Connection failed java.util.concurrent.TimeoutException: Idle timeout expired: 1000/1000 ms

Metadata

Metadata

Assignees

Labels

BugFor general bugs on Jetty side

Type

No type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions