armeria icon indicating copy to clipboard operation
armeria copied to clipboard

Make SessionProtocolNegotiationCache behavior configurable

Open yzfeng2020 opened this issue 7 months ago • 0 comments

We're encountering an issue where SessionProtocolNegotiationCache causes clients to persistently downgrade to HTTP/1.1 after a transient failure, even after the server becomes ready to support HTTP/2. This is particularly problematic when using tools like ngrok, which may initially respond with HTTP/1.1 while a tunnel is still initializing. Once the Armeria client receives this response, it caches the result and never retries with HTTP/2.

Proposed Improvements:

We would like to discuss possible enhancements to make the cache behavior more flexible. Some options are:

  1. Time-based expiration: Allow cached entries to expire after a configurable duration.

  2. Address-level opt-out: Provide a configuration mechanism to skip caching for a specific list of socket addresses.

  3. Global opt-out: Add a configuration toggle to disable SessionProtocolNegotiationCache entirely.

IMO, 1 and 3 can be implemented via an SPI-based cache configuration.

Let me know wdyt thanks!

https://discord.com/channels/1087271586832318494/1087272728177942629/1359366099145199798

yzfeng2020 avatar May 09 '25 00:05 yzfeng2020