Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpRequestException: Unable to get subchannel from HttpRequestMessage - .Net 7 - using Fiddler Everywhere #2254

Closed
rizi opened this issue Aug 24, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@rizi
Copy link

rizi commented Aug 24, 2023

What version of gRPC and what language are you using?

Grpc.Net.Client/Grpc.Net.ClientFactory 2.53.0, C#

What operating system (Linux, Windows,...) and version?

Windows 10 Enterprise (22H2)

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

.Net 7.0.400,

What did you do?

We are creating a grpc client as described here: https://learn.microsoft.com/en-us/aspnet/core/grpc/netstandard?view=aspnetcore-7.0.

Using the gRCP client works as expected as long as there is no proxy running (like Fiddler Everywhere), as soon as I start Fiddler Everywhere which supports HTTP 2 and gRPC capturing, we get an exception (see the section What did you see instead?),
is the configuration of the grpc client registration correct?

builder.Services
    .AddGrpcClient<Greeter.GreeterClient>(o =>
    {
        o.Address = new Uri("https://someAddress:5001");
    })
   .ConfigureChannel(options =>
                                               {
                                                   options.Credentials = new SslCredentials();

                                                   options.HttpHandler = new SocketsHttpHandler
                                                                         {
                                                                             PooledConnectionIdleTimeout = Timeout.InfiniteTimeSpan,
                                                                             KeepAlivePingDelay = TimeSpan.FromSeconds(50),
                                                                             KeepAlivePingTimeout = TimeSpan.FromSeconds(20),
                                                                             KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always,
                                                                             EnableMultipleHttp2Connections = true
                                                                         };
                                               });

What did you expect to see?

I would expect that the gRPC call successfully runs through the proxy and finally returns the result.

What did you see instead?

I see the following exception (note that 127.0.0.1:8866 is the address of fiddler, so the call is forwarded to the proxy)

Connection id "0HMT23GS5CF6U", Request id "0HMT23GS5CF6U:00000001": An unhandled exception was thrown by the application.

Error: Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Unable to get subchannel from HttpRequestMessage. (127.0.0.1:8866) InvalidOperationException: Unable to get subchannel from HttpRequestMessage.", DebugException="System.Net.Http.HttpRequestException: Unable to get subchannel from HttpRequestMessage. (127.0.0.1:8866)")
---> System.Net.Http.HttpRequestException: Unable to get subchannel from HttpRequestMessage. (127.0.0.1:8866)
---> System.InvalidOperationException: Unable to get subchannel from HttpRequestMessage.
 at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.OnConnect(SocketsHttpConnectionContext context, CancellationToken cancellationToken)
 at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)

This issue seems very similar: #2116

Note: using HttpClientHandler instead of SocketsHttpHandler does not cause an exception and the result from the gRPC call is returned correctly.

However the gRPC call is not captured by Fiddler and it is not an option, because the HttpClientHandler does not provide properties like PooledConnectionIdleTimeout , EnableMultipleHttp2Connections , KeepAlivePingPolicy, ...

Any help would highly be appreciated.

@rizi rizi added the bug Something isn't working label Aug 24, 2023
@JamesNK
Copy link
Member

JamesNK commented Sep 13, 2023

A limitation of gRPC load balancing is it doesn't work well with proxies. There isn't an ETA on when this will be fixed.

Configuring HttpClientHandler disables load balancing which is why it starts working.

@rizi
Copy link
Author

rizi commented Sep 13, 2023

A limitation of gRPC load balancing is it doesn't work well with proxies. There isn't an ETA on when this will be fixed.

Configuring HttpClientHandler disables load balancing which is why it starts working.

Can load balancing be deactivated using the SocketsHttpHandler?
If so are there any disadvantages?

Br

@JamesNK
Copy link
Member

JamesNK commented Dec 8, 2023

Can load balancing be deactivated using the SocketsHttpHandler? If so are there any disadvantages?

Yes, the latest version supports this: #2312 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants