Blazor: Grpc.Core.RpcException: Status(StatusCode="Cancelled", Detail="No grpc-status found on response.")
See original GitHub issueThrowing 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:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
See https://github.com/grpc/grpc-dotnet/blob/3518cd757002f5a685f34d277e876850b7637ecc/examples/Spar/Server/Startup.cs#L44
same error in UWP client app. how to config grpc-status header?