Skip to content

Use HTTP/1.1 when ALPN protocol is not specified - #162

Merged
3dgiordano merged 5 commits into
developmentfrom
FIX-ALPN-ABSENT-HTTP1-FALLBACK
Aug 21, 2026
Merged

Use HTTP/1.1 when ALPN protocol is not specified#162
3dgiordano merged 5 commits into
developmentfrom
FIX-ALPN-ABSENT-HTTP1-FALLBACK

Conversation

@3dgiordano

Copy link
Copy Markdown
Collaborator

This pull request introduces robust handling for servers that do not support HTTP/2, particularly when TLS ALPN negotiation fails and the server responds with HTTP/1.1. The changes ensure that such origins are remembered and future requests avoid attempting HTTP/2, improving efficiency and reliability, especially in multi-address scenarios. Additionally, the implementation prevents repeated failed HTTP/2 attempts for the same origin and adds comprehensive tests to validate the new behavior.

HTTP/2 Rejection Detection and Caching:

  • Added logic to detect when an origin rejects the HTTP/2 preface (e.g., due to missing ALPN negotiation) and remember that the origin should be accessed via HTTP/1.1 in the future (HTTP2JettyClient.java, CustomHttpSessionListenerPromise.java). [1] [2] [3]
  • Updated the HTTP/2 connection factory to accept a callback for HTTP/2 rejection, propagating this information through the connection setup process (CustomClientConnectionFactoryOverHTTP2.java). [1] [2] [3]

Connection Handling Improvements:

  • Modified the connection logic to immediately fallback to HTTP/1.1 for all addresses of an origin known to reject HTTP/2, preventing repeated failed connection attempts for each address (HTTP2JettyClient.java, RecordingHttpClientTransportDynamic).

Fallback Logic Enhancements:

  • Enhanced the fallback mechanism in request sending to trigger on both transport failures and HTTP/2 rejection, ensuring samples succeed whenever possible (HTTP2JettyClient.java).

Testing:

  • Added AlpnAbsentHttp2RejectedTest to reproduce and verify the handling of origins that do not negotiate ALPN, including scenarios with multiple resolved addresses and ensuring that repeated HTTP/2 attempts are avoided (AlpnAbsentHttp2RejectedTest.java).

Dependency and Import Updates:

  • Added necessary imports for new classes and interfaces used in the implementation (HTTP2JettyClient.java, CustomClientConnectionFactoryOverHTTP2.java, CustomHttpSessionListenerPromise.java). [1] [2] [3] [4]

These changes significantly improve the client's resilience and performance when interacting with servers that do not support HTTP/2, especially in complex network environments.

Base automatically changed from CONNECT-ATTEMPT-VISIBILITY to development August 21, 2026 18:00
@3dgiordano

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

…T-HTTP1-FALLBACK

# Conflicts:
#	src/main/java/com/blazemeter/jmeter/http2/core/HTTP2JettyClient.java

Co-authored-by: 3dgiordano <797057+3dgiordano@users.noreply.github.com>

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit 30a0ec4. The conflicts in HTTP2JettyClient.java were resolved by accepting the connectors/dnsResolver field declarations and setSourceAddress method from development, while preserving the infos field and newConnection override from this branch.

@3dgiordano
3dgiordano merged commit 6614fe0 into development Aug 21, 2026
2 checks passed
@3dgiordano
3dgiordano deleted the FIX-ALPN-ABSENT-HTTP1-FALLBACK branch August 21, 2026 18:17
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.

3 participants