Skip to content

Fix spurious TCP resets when initiating TLS connection closure - #898

Merged
rschmitt merged 1 commit into
apache:masterfrom
rschmitt:tls-graceful-close
Oct 16, 2026
Merged

rschmitt merged 1 commit into
apache:masterfrom
rschmitt:tls-graceful-close

Conversation

@rschmitt

Copy link
Copy Markdown
Contributor

When an HTTP/1.1 response contains Connection: close, the async client begins a graceful TLS shutdown. This causes SSLIOSession.isOpen() to immediately start returning false, so at the completion of the HTTP exchange when AsyncProtocolExec calls isEndpointConnected(), the InternalConnectionEndpoint.isConnected() method sees that the pool entry's underlying connection is reporting !isOpen() and calls poolEntry.discardConnection(CloseMode.IMMEDIATE), which sends a TCP reset to the server.

This commit changes that discardConnection call site to use CloseMode.GRACEFUL, and also provides a reproducer and integration test demonstrating the problem.

When an HTTP/1.1 response contains `Connection: close`, the async client
begins a graceful TLS shutdown. This causes `SSLIOSession.isOpen()` to
immediately start returning `false`, so at the completion of the HTTP
exchange when `AsyncProtocolExec` calls `isEndpointConnected()`, the
`InternalConnectionEndpoint.isConnected()` method sees that the pool
entry's underlying connection is reporting `!isOpen()` and calls
`poolEntry.discardConnection(CloseMode.IMMEDIATE)`, which sends a TCP
reset to the server.

This commit changes that `discardConnection` call site to use
`CloseMode.GRACEFUL`, and also provides a reproducer and integration
test demonstrating the problem.
@ok2c

ok2c commented Oct 14, 2026

Copy link
Copy Markdown
Member

Please also cheery-pick to 5.6.x

@rschmitt
rschmitt merged commit e413d1d into apache:master Oct 16, 2026
10 checks passed
@rschmitt
rschmitt deleted the tls-graceful-close branch October 16, 2026 16:56
@rschmitt

Copy link
Copy Markdown
Contributor Author

Cherry-picked to 5.6.x as 54c5ad8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants