Grpc-dotnet: Add support for grpc web

Created on 15 Feb 2019  路  6Comments  路  Source: grpc/grpc-dotnet

grpcWeb is a different protocol to grpc over HTTP/2. At some point we should add support for this.

https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md#protocol-differences-vs-grpc-over-http2

needs design

Most helpful comment

It would involve writing a custom CallInvoker, similar to the WIP managed .NET client.

There is nothing stopping someone writing one today in .NET Core 2.2. gRPC-web uses HTTP/1 tech which is fully supported by HttpClient.

All 6 comments

I want to be able to consume gRPC services from Blazor. You can read The state of gRPC in the browser. It is pretty easy to set up a gRPC-web proxy for a gRPC service, so it would be nice to be able to servce gRPC-web, but we can get by without out. What we really need is the gRPC-web client.

It would involve writing a custom CallInvoker, similar to the WIP managed .NET client.

There is nothing stopping someone writing one today in .NET Core 2.2. gRPC-web uses HTTP/1 tech which is fully supported by HttpClient.

I vote for this feature.

We intend to do a simple protobuf-over-websocket thing in our blazor app. I'm insisting we call it GhettoRPC. It's relatively easy because we don't absolutely need advanced gRPC features. But it is rather silly, and we'd prefer grpcWeb.

Would love support for this as well. I came up with a grpc-gateway-like solution where I convert calls so I could reach my api via Blazor WASM.

For anyone interested here is my project: https://github.com/razfriman/BlazorGrpc

For anyone looking to get a working gRPC server & client Blazor wasm app, I've created a simple proof of concept. The PoC uses a gRPC-web proxy hosted in a aspnet core service (KnowitSolutions created the gRPC-web proxy), and consumes it in the blazor wasm app using a basic CallInvoker (created by SteveSandersonMS).

The example does use grpc code first libraries, but is pretty easy to convert to the contract first setup. From the top of my head;

  1. Replace the protobuf-net.Grpc.AspNetCore nuget ref with the MS gRPC nuget ref
  2. Replace AddCodeFirstGrpc with AddGrpc in Startup.cs
  3. Create your service the contract first way
  4. new your client with the GrpcWebCallInvoker instead of using the ClientFactory
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajeshaz09 picture rajeshaz09  路  5Comments

shawnwildermuth picture shawnwildermuth  路  4Comments

heartacker picture heartacker  路  3Comments

JamesNK picture JamesNK  路  3Comments

JamesNK picture JamesNK  路  6Comments