Skip to content

fix(crt): time out HTTP/2 stream acquisition - #7578

Open
zoewangg wants to merge 4 commits into
zoewang/crt-max-pending-acquiresfrom
zoewang/crt-h2-stream-acquisition-timeout
Open

zoewangg wants to merge 4 commits into
zoewang/crt-max-pending-acquiresfrom
zoewang/crt-h2-stream-acquisition-timeout

Conversation

@zoewangg

@zoewangg zoewangg commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #7522** (maxPendingConnectionAcquires);

Motivation and Context

connectionAcquisitionTimeout is not honored in AwsCrtAsyncHttpClient HTTP/2 code path today. The new aws-crt-java release adds an HTTP/2 stream acquisition timeout, so the CRT client can apply connectionAcquisitionTimeout the same way.

Modifications

  • On HTTP/2, connectionAcquisitionTimeout (10 seconds by default) is passed to Http2StreamManagerOptions.withStreamAcquisitionTimeoutInMilliseconds, so it bounds both the wait for a stream and the wait for a new connection. Existing HTTP/2 users whose requests wait longer than the timeout now get an error instead of waiting.
Caused by: java.io.IOException: Acquire operation took longer than the configured maximum time. This indicates that a request cannot get a connection or stream from the pool within connectionAcquisitionTimeout. This can be due to high request rate. This can also happen when a new connection cannot be established in time, for example a slow or failing TLS handshake.
Consider taking any of the following actions to mitigate the issue: increase maxConcurrency, increase connectionAcquisitionTimeout, or slow the request rate.
Increasing maxConcurrency can increase client throughput (unless the network interface is already fully utilized), but can eventually start to hit operating system limitations on the number of file descriptors used by the process. If you are already fully utilizing your network interface or cannot further increase maxConcurrency, increasing connectionAcquisitionTimeout gives requests more time to acquire a connection or stream before timing out. If connections and streams don't free up, later requests will still time out.
If the above mechanisms are not able to fix the issue, try smoothing out your requests so that large traffic bursts cannot overload the client, being more efficient with the number of times you need to call AWS, or by increasing the number of hosts sending requests.
  • Also updated the error message for HTTP/1.1 to be consistent.

Testing

  • add new functional tests and unit tests
  • add new shared H2 test suites
  • update existing H1 test suites to cover this

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

AI tools

  • I wrote this pull request description myself, not with an AI tool
  • I have reviewed all changes in this pull request myself, including any generated by AI tools

License

  • I confirm that this pull request can be released under the Apache 2 license

@zoewangg
zoewangg requested a review from a team as a code owner November 23, 2026 18:06
@zoewangg
zoewangg added this pull request to stack #7579 November 23, 2026 18:06
@zoewangg
zoewangg force-pushed the zoewang/crt-h2-stream-acquisition-timeout branch 2 times, most recently from 03b1eab to 7b03c19 Compare November 24, 2026 15:41
"type": "bugfix",
"category": "AWS CRT HTTP Client",
"contributor": "",
"description": "`AwsCrtAsyncHttpClient` now applies `connectionAcquisitionTimeout` to HTTP/2 requests waiting for a stream when all `maxConcurrency` streams are in use, or for a new connection, matching the Netty client. Previously these requests waited without a time limit. Requests that wait longer than the acquisition timeout (10 seconds by default) now fail with an `IOException`, like the HTTP/1.1 acquisition timeout. To allow longer waits, increase `maxConcurrency` or `connectionAcquisitionTimeout`."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a duplicate change log, can we keep just one ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are actually different. This one describes the behavior change and the other one describes the error message change.

On HTTP/2, map connectionAcquisitionTimeout to the stream manager's
acquisition timeout, so a request waiting for a stream or a new
connection fails after it, as on Netty. Set the connection manager's
own acquisition timeout to 0 on HTTP/2 so the two timers cannot race.
The timeout (2097) fails with an IllegalStateException whose message
starts with the Netty client's acquire-timeout sentence, and is not
retried. Requires an aws-crt release that includes aws-crt-java#1032.
Surface the HTTP/2 stream acquisition timeout (2097) as an IOException
carrying the CRT error text, with the CRT error as the cause, matching
the HTTP/1.1 acquisition timeout (2093), instead of an
IllegalStateException.
Report the HTTP/1.1 connection acquisition timeout (2093) and the HTTP/2
stream acquisition timeout (2097) as an IOException whose message starts
with Netty's acquire-timeout sentence, followed by advice naming the CRT
options, with the CRT error as the cause.
Add optional per-client hooks to the long-running request suites that check
the acquire-timeout failure's message prefix and cause type, and a shared
HTTP/2 acquire-timeout suite that CRT and Netty run. Move
DeferredResponseServer to http-client-tests and replace the CRT-only
acquisition timeout tests with the shared suites.
@zoewangg
zoewangg force-pushed the zoewang/crt-h2-stream-acquisition-timeout branch from 2116ffe to 72275c0 Compare November 25, 2026 23:40
@zoewangg zoewangg added the no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required label Nov 25, 2026
@zoewangg
zoewangg enabled stacked auto-merge November 25, 2026 23:42

This branch has not been deployed

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

Labels

no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants