forked from vishnukv-facets/grpc-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
22 lines (16 loc) · 743 Bytes
/
client.py
File metadata and controls
22 lines (16 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import grpc
import greeter_pb2
import greeter_pb2_grpc
def run():
# Replace "your_server_domain.com" with the DNS name of your Ingress
target = "<dns of external facing LB>"
# Create the channel credentials
creds = grpc.ssl_channel_credentials()
# Override the target name to match the certificate's Common Name (CN) or Subject Alternative Name (SAN)
channel = grpc.secure_channel(target, creds, options=(('grpc.ssl_target_name_override', '<dns of external facing LB>'),))
# Create the gRPC stub
stub = greeter_pb2_grpc.GreeterStub(channel)
response = stub.SayHello(greeter_pb2.HelloRequest(name="Vishnu"))
print("Greeter client received: " + response.message)
if __name__ == "__main__":
run()