fix: disable gRPC client-side load balancing on channels (#33) - #40
Open
Doremi203 wants to merge 1 commit into
Open
fix: disable gRPC client-side load balancing on channels (#33)#40Doremi203 wants to merge 1 commit into
Doremi203 wants to merge 1 commit into
Conversation
Grpc.Net.Client >= 2.44 enables client-side load balancing, which routes calls through BalancerHttpHandler. Behind an HTTP proxy this breaks and surfaces as "Unable to get subchannel from HttpRequestMessage" or an HTTP/2 COMPRESSION_ERROR, making the SDK unusable for any call to Yandex Cloud (e.g. Lockbox) in such environments. The SDK always connects to a single resolved endpoint, so load balancing is unnecessary. Supplying an explicit HttpClient to GrpcChannelOptions disables it and uses a plain HTTP/2 connection. Fixes yandex-cloud#33. See grpc/grpc-dotnet#2254; mirrors ydb-platform/ydb-dotnet-sdk#219.
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.
Problem
Since
Grpc.Net.Client2.44, gRPC enables client-side load balancing, which routes every call throughBalancerHttpHandler. The SDK builds its channels without an explicitHttpClient, so all calls go through the balancer.In environments where the balancer's connection handling is involved (e.g. behind an HTTP proxy), this breaks and surfaces as either:
InvalidOperationException: Unable to get subchannel from HttpRequestMessage, orGrpc.Core.RpcException: Status(StatusCode="Internal", ... HTTP/2 error code 'COMPRESSION_ERROR' (0x9))The failure happens on the very first call — endpoint discovery via
ApiEndpointService(api.cloud.yandex.net) — so the SDK is effectively unusable for any service (Lockbox, etc.) in such environments.Fixes #33.
Root cause
The SDK always connects to a single resolved endpoint, so gRPC client-side load balancing is unnecessary — but it is on by default in
Grpc.Net.Client >= 2.44whenever the channel is created without an explicitHttpClient.Fix
Supply an explicit
HttpClienttoGrpcChannelOptions, which disables client-side load balancing and uses a plain HTTP/2 connection. This is one of the documented workarounds for grpc/grpc-dotnet#2254 and mirrors the fix accepted in the YDB .NET SDK (ydb-platform/ydb-dotnet-sdk#219).All channels (the API-endpoint channel and every per-service channel) go through this single
GetChannel, so the one-line change covers the whole SDK.Notes / verification
Generated.cs) that I couldn't bootstrap locally, so I verified the change by compiling the modifiedGetChannelagainst the SDK's transitiveGrpc.Net.Client2.61.0 onnetstandard2.0, and by running it end-to-end against Lockbox from a downstream .NET 9 service (the exactHttpClient+GrpcChannelOptionsshape), where it resolves theCOMPRESSION_ERROR.Credentials(TLS + the auth-tokenCallCredentialsinterceptor) is preserved; only the transport handler changes.I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en