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.

Blazor: Grpc.Core.RpcException: Status(StatusCode="Cancelled", Detail="No grpc-status found on response.")

See original GitHub issue

Throwing RpcException on the server always results in

Grpc.Core.RpcException: Status(StatusCode=“Cancelled”, Detail=“No grpc-status found on response.”)

being raised in a Blazor webassembly client.

What version of gRPC and what language are you using?

2.34.0 C#

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

Windows 10

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

.NET 5

What did you do?

(see here for demo project)

Created a GRPC service from the VS template, enabled Cors, enabled Grpc-Web. Changed the Kestrel endpoints protocol in appsettings.json from Http2 to Http.

GreeterService.cs

public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
{
    throw new RpcException(new Status(StatusCode.AlreadyExists, "already exists detail"));
}

Created a Blazor web-assembly project.

Index.razor

@page "/"
@inject GrpcGreeter.Greeter.GreeterClient Client
<button @onclick="CallSayHello">Call Say Hello</button>
@code {
    private async Task CallSayHello()
    {
        await Client.SayHelloAsync(new GrpcGreeter.HelloRequest() { Name = "Mark" });        
    }
}

Program.cs

builder.Services.AddScoped(services =>
{
    var httpClient = new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler()));
    var channel = GrpcChannel.ForAddress(ServerAddress, new GrpcChannelOptions { HttpClient = httpClient });
    return new GrpcGreeter.Greeter.GreeterClient(channel);
});

I have confirmed the correct error is being generated by the server with grpcurl…

grpcurl -d “{"name":"Mark"}” localhost:6001 greet.Greeter/SayHello ERROR: Code: AlreadyExists Message: already exists detail

Also, Fiddler reports the response from the Blazor request as

HTTP/1.1 200 OK Date: Thu, 24 Dec 2020 11:42:48 GMT Content-Type: application/grpc-web Server: Kestrel Content-Length: 0 Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: https://localhost:44326 Grpc-Status: 6 Grpc-Message: already exists detail

What did you expect to see?

The server generated RpcException passed to the client.

What did you see instead?

Grpc.Core.RpcException: Status(StatusCode=“Cancelled”, Detail=“No grpc-status found on response.”)

Issue Analytics

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

github_iconTop GitHub Comments

0reactions
HppZcommented, Mar 23, 2021

same error in UWP client app. how to config grpc-status header?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor: Grpc.Core.RpcException: Status(StatusCode= ...
RpcException : Status(StatusCode="Cancelled", Detail="No grpc-status found on response.") being raised in a Blazor webassembly client.
Read more >
net core 3.0 grpc error statucode=canceled
I got an error when using grpc in .net core 3.0,. Here is error message: [Grpc.Core.RpcException:“Status(StatusCode=Cancelled, Detail="No grpc- ...
Read more >
Troubleshoot gRPC on .NET
Call insecure gRPC services with .NET Core client. The .NET gRPC client can call insecure gRPC services by specifing http in the server...
Read more >
GRPC Core: Status codes and their use in gRPC
Code Number Description OK 0 Not an error; returned on success. FAILED_PRECONDITION 9 OUT_OF_RANGE 11
Read more >
Error handling - gRPC for WCF Developers
The RpcException must include a status code and description, and can optionally include metadata and a longer exception message. The metadata ...
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