Skip to content

skbeez/GrpcServerClientExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GrpcServerClientExample

Python implementation of a gRPC Server and Client (based on this repo) with an Envoy that can interact with gRPC web applications.

Getting Started

Install the Envoy in MacOS

brew install envoy

Install Grpc Tools

pip3 install grpcio-tools

Generate gRPC code based on proto file

python3 -m grpc_tools.protoc --python_out=protobufs/ --grpc_python_out=protobufs/ -I protos protos/greet.proto

Options Explained

--python_out:       Is where you want the autogenerated gRPC protocol buffers code to go  
--grpc_python_out:  Is where you want the autogenerated gRPC python protocols code to go  
-I:                 Points to the folder where the protos are stored  
  
The last argument is the exact proto file you want to use within the folder identified in the -I argument  

Set Up the Envoy (if necessary)

If you have gRPC web app that you need to connect to the gRPC server, you will need an Envoy. Current web broswers cannot communicate over http2 so the envoy acts as an intermediatry between http2 and http1.

envoy -c envoy.yaml

Note: Ensure that the your web app connects to the Envoy's port and not the gRPC server's port (in this example the Envoy is on port 1025).

Run the gRPC Server

python3 server.py

Run the gRPC Client

python3 client.py

Creating the Web App

npx create-react-app grpc-web-app
cd grpc-web-app
npm install bootstrap react-bootstrap
npm start

Add the following line at the top of src/index.js

import 'bootstrap/dist/css/bootstrap.min.css';

About

Python implementation of a Graph Server and Client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published