question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting error "HttpRequestException: Unable to get subchannel from HttpRequestMessage." after upgrading from .NET Core 3.1 to .NET 6.0

See original GitHub issue

What version of gRPC and what language are you using?

Grpc.Net.Client : 2.51.0 C#

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

Windows

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

.NET 6.0

What did you do?

Updated the project from .NET Core 3.1 to .NET 6.0

What did you expect to see?

Grpc calls working fine

What did you see instead?

Seeing error “HttpRequestException: Unable to get subchannel from HttpRequestMessage.” at one of our customers that use a proxy server.

Creating the GRPC channel as below

var channel = GrpcChannel.ForAddress(URI);

Stack Trace Status(StatusCode=“Internal”, Detail=“Error starting gRPC call. HttpRequestException: Unable to get subchannel from HttpRequestMessage. (proxy URI) InvalidOperationException: Unable to get subchannel from HttpRequestMessage.”, DebugException=“System.Net.Http.HttpRequestException: Unable to get subchannel from HttpRequestMessage. (proxy URI) —> 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) — End of inner exception stack trace — at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request) at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.EstablishProxyTunnelAsync(Boolean async, HttpRequestHeaders headers, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp2ConnectionAsync(HttpRequestMessage request) at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp2ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Grpc.Net.Client.Internal.GrpcCall2.RunCall(HttpRequestMessage request, Nullable1 timeout)”)|

Anything else we should know about your project / environment?

Customer environment use a proxy server. The issue is seen after updating from .NET Core 3.1 to .NET 6.0

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
johnkorscommented, Jul 6, 2023

I forgot I had Proxyman (Fiddler alt for Mac) running and got this same exact error on my dev machine. 🤦

0reactions
rizicommented, Aug 21, 2023

@JamesNK we have exact the same problem in .Net 7.0 when we use Fiddler Everywhere, I’m not sure what we have to do to make it work with Fiddler, just add new GrpcChannelOptions { Handler = new HttpClientHandler() });?

If adding the HttpClientHandler is enough, could you please elaborate what this is doing and why we need that?

br

Read more comments on GitHub >

github_iconTop Results From Across the Web

When making Grpc request over http in .net core creates ...
HttpRequestException : An error occurred while sending the request. IOException: The request was aborted. Http2ConnectionException: The HTTP/2 ...
Read more >
Troubleshoot gRPC on .NET
The following error message is returned when calling a gRPC service without a trusted certificate: Unhandled exception. System.Net.Http.
Read more >
Building a Reverse Proxy in .NET Core
The client requests a resource to the proxy server which retrieves it from another server and provides it to the client. In this...
Read more >
Demystifying HttpClient Internals: HttpResponseMessage
In this post we'll look at and demystify the internals of the HttpResoinseMessage class, returned by requests from HttpClient.
Read more >
Better timeout handling with HttpClient - Thomas Levesque
The exception thrown when the timeout is elapsed doesn't let you determine the cause of the error. When a timeout occurs, you'd expect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found