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.

Grpc.Net.Client.Web: Request with RepeatedField Throws InvalidOperationException when GrpcWebText Mode is set

See original GitHub issue

Hello,

I’m trying out the experimental Grpc-Web functionality. On the client side, in Startup.cs, I have:

   var handler = new GrpcWebHandler(GrpcWebMode.GrpcWebText, new HttpClientHandler());

   return new TheBook.TheBookClient(GrpcChannel.ForAddress(":url-to-service:"), new GrpcChannelOptions
            {
                HttpClient = new HttpClient(handler)
            }));

The request I’m sending looks like this (Value is string; the Carriers property is Google.Protobuf.Collections.RepeatedField<string>):

    var getLibraryRequest = new GetLibraryRequest() { UserId = userId, SearchTerm = SearchTerm ?? "" };

    getLibraryRequest.Carriers.AddRange(userAssociations.Where(c => c.Type == "Carrier").Select(c => c.Value));
    var result = await _Client.GetLibraryAsync(getLibraryRequest);

This throws on the client side. After enabling Grpc: Debug in the Logging section in appsettings.json, this is revealed:

Exception thrown: 'System.InvalidOperationException' in Grpc.Net.Client.Web.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in Grpc.Net.Client.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Net.Http.dll
Exception thrown: 'System.IO.IOException' in System.Net.Http.dll
Exception thrown: 'System.IO.IOException' in System.Net.Http.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in System.Private.CoreLib.dll

If I set GrpcWebMode.GrpcWeb in Startup.cs, the request sends, successfully hits the gRPC service, and completes successfully.

Is GrpcWebText to only be used in situations where you do not need a repeated field? Is there a misunderstanding on my side?

Thank you, Joseph A. Pietrzak, Jr.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JamesNKcommented, Feb 12, 2020

Lets close it

0reactions
joepietrzakcommented, Feb 12, 2020

James,

Okay thank you for the acknowledgement and clarification. I have been using GrpcWeb mode and it handles those large requests well and has been working well in general.

Should I leave this Issue open for your process? Or close it since you have answered my questions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - .NET 5 GRPC client call throws exception: Requesting ...
My company proxy appears to be interfering with HTTP/2 (unsupported?), preventing gRPC from working correctly. The workaround for local ...
Read more >
Troubleshoot gRPC on .NET
NET Core client. The .NET gRPC client can call insecure gRPC services by specifing http in the server address. For example, GrpcChannel.
Read more >
Grpc.Net.Client.Web 2.55.0
GrpcWebMode.GrpcWebText configures content to be base64 encoded. Required for server streaming calls in browsers. HttpVersion: HTTP protocol Version used to set ...
Read more >
ServiceStack gRPC
Requests are executed using the RpcGateway which provides a pure object model for executing the full HTTP Request pipeline which returns the Response...
Read more >
Introduction to gRPC in .NET Core and .NET 5
gRPC is a high-performance RPC framework with pluggable authentication and load balancing features. In this post, you will learn about gRPC ...
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