Skip to content

Some Http2ClientConnections remain open despite the Http2KeepAliveTimeout #5580

@edu-gimenez

Description

@edu-gimenez

Version

vertx-core:4.5.15

Context

We are using a Vert.x client under heavy load, and we noticed that some connections are never released after the traffic finishes even with a Http2KeepAliveTimeout configured.

We found that these connections had their lastStreamId set to 0. So, I believe the problem is that these connections never had a valid stream. As a result, the Http2ClientConnection.recycle() method is never called, and the expirationTimestamp field is not updated, so the connection is never released due to the keepAliveTimeout.

I have fixed it by adding in the constructor:

Http2ClientConnection(
      HttpClientBase client,
      ContextInternal context,
      VertxHttp2ConnectionHandler connHandler,
      ClientMetrics metrics) {
    super(context, connHandler);
    this.metrics = metrics;
    this.client = client;
    
    // We set the keep-alive timeout from the beginning
    int timeout = client.options().getHttp2KeepAliveTimeout();
    this.expirationTimestamp = timeout > 0 ? System.currentTimeMillis() + timeout * 1000L : 0L;
  }

What do you think about this? Could this change have a side effect, or is it fine as it is?
Thx!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions