Get the example code
The example code is part of the
Dowload the repo as a zip file and unzip it, or clone
$ git clone https://github.com/grpc/grpc-web
Change to the repo’s root directory:
Run an Echo example from your browser!
Fetch required packages and tools:
Getting the following warning? You can ignore it for the purpose of running the
WARNING: Some service image(s) must be built from source
Launch services as background processes:
$ docker-compose up -d node-server envoy commonjs-client
From your browser:
You’ll see your message echoed by the server below the input box.
Congratulations! You’ve just run a client-server application with gRPC.
Once you are done, shutdown the services that you launched earlier by running
the following command:
What is happening?
This example app has three key components:
node-server is a standard gRPC server, implemented in Node. This server
listens at port
:9090, and implements the app’s business logic (echoing
envoy is the Envoy proxy. It listens at
:8080 and forwards the browser’s
gRPC-Web requests to port
commonjs-client: this component generates the client stub class using the
protoc-gen-grpc-web protoc plugin, compiles all the JS dependencies using
webpack, and hosts the static content (
:8081 using a simple web server. User messages entered from the
webpage are sent to the Envoy proxy as gRPC-web requests.