• Home
Name
Date
Size
#Lines
LOC

..--

Greeter/12-May-2024-2116

GreeterClient/12-May-2024-6540

GreeterServer/12-May-2024-10773

Greeter.slnD12-May-20241.9 KiB3533

README.mdD12-May-20242.3 KiB10077

README.md

1gRPC Hostname example (C#)
2========================
3
4BACKGROUND
5-------------
6This is a version of the helloworld example with a server whose response includes its hostname. It also supports health and reflection services. This makes it a good server to test infrastructure, such as XDS load balancing.
7
8PREREQUISITES
9-------------
10
11- The [.NET Core SDK 2.1+](https://www.microsoft.com/net/core)
12
13You can also build the solution `Greeter.sln` using Visual Studio 2019,
14but it's not a requirement.
15
16RUN THE EXAMPLE
17-------------
18
19First, build and run the server, then verify the server is running and
20check the server is behaving as expected (more on that below).
21
22```
23cd GreeterServer
24dotnet run
25```
26
27After configuring your xDS server to track the gRPC server we just started,
28create a bootstrap file as desribed in [gRFC A27](https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md):
29
30```
31{
32  xds_servers": [
33    {
34      "server_uri": <string containing URI of xds server>,
35      "channel_creds": [
36        {
37          "type": <string containing channel cred type>,
38          "config": <JSON object containing config for the type>
39        }
40      ]
41    }
42  ],
43  "node": <JSON form of Node proto>
44}
45```
46
47Then point the `GRPC_XDS_BOOTSTRAP` environment variable at the bootstrap file:
48
49```
50export GRPC_XDS_BOOTSTRAP=/etc/xds-bootstrap.json
51```
52
53Finally, run your client:
54
55```
56cd GreeterClient
57dotnet run --server xds-experimental:///my-backend
58```
59
60VERIFYING THE SERVER
61-------------
62
63`grpcurl` can be used to test your server. If you don't have it,
64install [`grpcurl`](https://github.com/fullstorydev/grpcurl/releases). This will allow
65you to manually test the service.
66
67Exercise your server's application-layer service:
68
69```sh
70> grpcurl --plaintext -d '{"name": "you"}' localhost:50051
71{
72  "message": "Hello you from jtatt.muc.corp.google.com!"
73}
74```
75
76Make sure that all of your server's services are available via reflection:
77
78```sh
79> grpcurl --plaintext localhost:50051 list
80grpc.health.v1.Health
81grpc.reflection.v1alpha.ServerReflection
82helloworld.Greeter
83```
84
85Make sure that your services are reporting healthy:
86
87```sh
88> grpcurl --plaintext -d '{"service": "helloworld.Greeter"}' localhost:50051
89grpc.health.v1.Health/Check
90{
91  "status": "SERVING"
92}
93
94> grpcurl --plaintext -d '{"service": ""}' localhost:50051
95grpc.health.v1.Health/Check
96{
97  "status": "SERVING"
98}
99```
100