From the course: gRPC in Python

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Creating a client

Creating a client

- [Instructor] Let's create a client. So we import GRPC, our logging system and the generated GRPC bindings. Now I'm defining my own client and the init gets the address of the server to connect to. It creates a channel, which is an insecure channel, since our server is listening on HTTP and not HTPS. Then it generates a stub that comes from the generated bindings. And finally, it logs that it is connected. And we also add a closed method. And in our main, we import the configuration, create the address and then create the client. Let's run it. And we see that the code is running and it says it connected to the server even though the server is not running. And this is because the GRPC client, by default, will only try to initiate connection when you call methods.

Contents