Skip to content

Latest commit

 

History

History

web

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

An example of gRPC-Web via grpc-dart

Created from templates made available by Stagehand under a BSD-style license.

How to run this example

Start a server for client-side development by executing the following command in the root folder of this example.

$ webdev serve

Once the server has started, open http://localhost:8080/ in a browser.

Server

Set up a proxy following the steps in the next section, and then run a gRPC server with the command below.

$ dart ../unary_greet/bin/server.dart -p 9090

bin/server.dart of unary_greet is used here too since both examples use the same proto file.

Proxy

Unlike other examples in this repository, this one uses gRPC-Web that requires a proxy on the server side.

The following settings set up a Docker container with a proxy (Envoy) in it that listens on the port 50051 of the host machine and proxies to the port 9090, which the server should listen on.

  1. The value of address on the last line of envoy.yaml may need to be changed depending on your environment. See the README of gRPC-Web's helloworld for more information.
  2. Build a Docker image by running the following command in the folder where envoy.Dockerfile is located.
$ cd path/to/proxy_exmple
$ docker build -t greet/envoy -f .
  1. Create a container and start it with the command below. If necessary, change 50051 to another port you want the proxy to listen on.
$ docker run -d -p 50051:8080 --name greet_proxy greet/envoy
  1. cd to the root folder of the unary_greet example and start a server with the port number 9090 passed by the -p flag. Change the number accordingly if you have specified a different one on the last line of your envoy.yaml.
$ dart bin/server.dart -p 9090

Other options for a proxy

You can use some other tools instead as shown in README of gRPC-Web: