Created from templates made available by Stagehand under a BSD-style license.
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.
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.
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.
- 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. - 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 .
- 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
cd
to the root folder of the unary_greet example and start a server with the port number9090
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
You can use some other tools instead as shown in README of gRPC-Web: