gRPC server for Remote Piano
$ dart bin/server.dart -p {port number}
Port 50051 is used as the default if -p
option is omitted.
The web version of Remote Piano uses gRPC-Web
instead of grpc-dart
.
gRPC-Web does not directly connect to a server but to a proxy before a server.
How to set up a proxy (Envoy)
The following settings set up a Docker container with a proxy in it that listens on the port 50051 of the host machine and proxies to the port 9090, which the server should listen on.
- Copy
envoy.Dockerfile
andenvoy.yaml
inproxy_example
to your preferred directory. - 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.
$ docker build -t piano/envoy -f ./envoy.Dockerfile .
- 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 piano_proxy piano/envoy
- Move back to the root folder of this 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
You can use some other tools instead as shown in README of gRPC-Web: