How to bring a gRPC defined API to the web browser

Edit: Since Oct 23,2018 the gRPC-Web project is GA, which might be the most official/standardized way to solve your problem. (Even if it’s already 2018 now… 😉 ) From the GA-Blog: “gRPC-Web, just like gRPC, lets you define the service “contract” between client (web) and backend gRPC services using Protocol Buffers. The client can then … Read more

Testing a gRPC service

I think you’re looking for the google.golang.org/grpc/test/bufconn package to help you avoid starting up a service with a real port number, but still allowing testing of streaming RPCs. import “google.golang.org/grpc/test/bufconn” const bufSize = 1024 * 1024 var lis *bufconn.Listener func init() { lis = bufconn.Listen(bufSize) s := grpc.NewServer() pb.RegisterGreeterServer(s, &server{}) go func() { if err … Read more

How is GRPC different from REST?

The transport layer works using HTTP/2 on top of TCP/IP. It allows for lower latency (faster) connections that can take advantage of a single connection from client to server (which makes more efficient use of connection and can result in more efficient use of server resources. HTTP/2 also supports bidirectional connectivity and asynchronous connectivity. So … Read more

What is the difference between grpc and websocket? Which one is more suitable for bidirectional streaming connection?

gRPC is not really the relevant part for comparison, it’s that gRPC uses HTTP/2 which can certainly be compared to WebSockets. https://www.infoq.com/articles/websocket-and-http2-coexist This article outlines them quite well. Essentially, HTTP/2 is Client/Server with Server Push on the background, so you can make your request and simply stay on that connection listening for updates without the … Read more

protobuf vs gRPC

Protocol buffers is (are?) an Interface Definition Language and serialization library: You define your data structures in its IDL i.e. describe the data objects you want to use It provides routines to translate your data objects to and from binary, e.g. for writing/reading data from disk gRPC uses the same IDL but adds syntax “rpc” … Read more