fix(sources): default ALPN to h2 for gRPC-based sources when TLS is enabled - #25975
Draft
vladimir-dd wants to merge 1 commit into
Draft
fix(sources): default ALPN to h2 for gRPC-based sources when TLS is enabled#25975vladimir-dd wants to merge 1 commit into
vladimir-dd wants to merge 1 commit into
Conversation
…nabled gRPC always runs over HTTP/2, and HTTP/2 clients require the server to confirm `h2` via ALPN post-handshake (RFC 7540 Section 3.3). None of Vector's gRPC-based sources (e.g. `opentelemetry`) expose an `alpn_protocols` config option, so when TLS is enabled without one, strict gRPC clients fail the handshake with errors like `Cannot check peer: missing selected ALPN property.` Add `TlsSettings::set_default_alpn_protocols`/`MaybeTlsSettings::set_default_alpn_protocols`, which set a default ALPN protocol list only if the user hasn't already configured one, and call it with `["h2"]` from `run_grpc_server`/`run_grpc_server_with_routes` so every gRPC-based source gets the correct default without needing per-source config plumbing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
vladimir-dd
force-pushed
the
fix/otlp-grpc-tls-alpn-h2
branch
from
July 30, 2026 12:34
27058f6 to
78d55ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gRPC always runs over HTTP/2, and HTTP/2 clients require the server to confirm
h2via ALPN post-handshake (RFC 7540 Section 3.3). None of Vector's gRPC-based sources (e.g.opentelemetry) expose analpn_protocolsconfig option, so when TLS is enabled without one, strict gRPC clients (e.g. Go'sgrpc-go≥ v1.67, and by extensiongrpc-go-based tools/proxies) fail the handshake with:This adds
TlsSettings::set_default_alpn_protocols/MaybeTlsSettings::set_default_alpn_protocols, which set a default ALPN protocol list only if the user hasn't already configuredtls.alpn_protocolsexplicitly, and calls it with["h2"]from the sharedrun_grpc_server/run_grpc_server_with_routeshelpers insrc/sources/util/grpc/mod.rs. Fixing it at that shared layer means every current and future gRPC-based source gets the correct default without needing per-source config plumbing.This is narrowly scoped to TLS: plaintext gRPC (h2c) has no ALPN step at all (ALPN is a TLS-handshake-only extension per RFC 7301), so it's unaffected and continues to work as before.
Related prior ALPN-default bugs fixed in this codebase, for context: #18842/#18843 (
http_serversource didn't honortls.alpn_protocols) and #25805/#25807 (mqttsink hardcoded ALPN instead of honoringtls.alpn_protocols).Vector configuration
How did you test this PR?
lib/vector-core/src/tls/settings.rscovering: default ALPN applies when unset, explicitalpn_protocolsconfig is preserved (not overridden), andMaybeTlsSettings::set_default_alpn_protocolsis a no-op when TLS is disabled.cargo test -p vector-core --lib tls::settings::test— 18/18 pass.cargo test --lib --features sources-opentelemetry sources::opentelemetry— 24/24 pass.cargo clippy -p vector-core --lib -- -D warnings— clean.opentelemetrysource's gRPC listener: confirmed the exactmissing selected ALPN propertyhandshake failure before this change, and confirmed a successful handshake/export after.Is this a breaking change?
Does this PR include user facing changes?
changelog.d/grpc_sources_default_alpn_h2.fix.md.References
Notes
Generated with Claude Sonnet 5 as a coding assistant; I've read, tested, and take ownership of these changes per the AI Policy. Opening as a draft first to get early feedback on the approach (fixing at the shared
run_grpc_serverlayer vs. per-source) before requesting review.