Skip to content

reactor.netty.http.server.connections.active keeps increasing on each request, not decrementing after idle timeout #3723

@sbxz

Description

@sbxz

Hi,

I'm running some tests on my WebFlux application and, after enabling Netty metrics, I noticed that the reactor.netty.http.server.connections.active metric keeps increasing, even though I’ve configured an idle timeout of 5 seconds. It looks more like a bug in how the metric is decremented rather than an actual connection leak, since reactor.netty.http.server.connections.total seems to behave as expected.

Expected Behavior

The reactor.netty.http.server.connections.active metric should not increment on every request, but only when a new connection is established.

Actual Behavior

The reactor.netty.http.server.connections.active metric increments with each request, but only decrements when the connection is explicitly closed — so the value keeps going up over time.

After a bit of debugging, I noticed that MicrometerHttpServerMetricsRecorder.recordServerConnectionActive is called on every request, but MicrometerHttpServerMetricsRecorder.recordServerConnectionInactive is only called when the connection is actually closed.

If I add the Connection: close header, then the connection is properly closed at the end of the request, and the metric behaves correctly.

Steps to Reproduce

Here is a minimal application that reproduces the issue:

👉 https://github.com/sbxz/reactorNettyHttpServerConnectionsActive

Make multiple requests to http://localhost:8080/actuator/metrics/reactor.netty.http.server.connections.active using Postman or a browser (with curl, it seems the connection is closed properly), and you'll notice the metric keeps increasing — even after waiting more than 5 seconds.

Your Environment

spring-boot-starter-webflux : 3.4.4
reactor-netty-core : 1.2.4
reactor-core : 3.7.4
java : 21

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions