GrpcReplay is a network monitoring tool that can record your grpc traffic (Unary RPC) and use it for grayscale testing, stress testing or traffic analysis.
Python/Java/Golang gRPC all passed the test
Ubuntu
apt-get install -y libpcap-dev
Centos
yum install -y libpcap-devel
Mac
brew install libpcap
make build
sudo -s
Capture gRPC request on "0.0.0.0:35001" and print in console
./grpcr --input-raw="0.0.0.0:35001" --output-stdout
Capture gRPC request on "127.0.0.1:35001" and print in console
./grpcr --input-raw="127.0.0.1:35001" --output-stdout
Capture the gRPC request on "127.0.0.1:35001", send it to "127.0.0.1:35002", and print it in the console
./grpcr --input-raw="127.0.0.1:35001" --output-stdout --output-grpc="grpc://127.0.0.1:35002"
Set the value of codec, optional value: "simple" | "json"
./grpcr --input-raw="127.0.0.1:35001" --output-stdout --codec="simple"
Capture the gRPC request on "127.0.0.1:35001" and record it in a folder. The file is divided according to the maximum limit of 500MB and compressed. Note: The directory must already exist and be writeable.
./grpcr --input-raw="127.0.0.1:35001" --output-file-directory="/tmp/mycapture" --output-file-max-size=500
Read gRPC requests from a folder and replay them. gRPC requests will be sent to "127.0.0.1:35002" and printed in the console
./grpcr --input-file-directory="/tmp/mycapture" --output-stdout --output-grpc="grpc://127.0.0.1:35002"
Hint: You can use input-file-replay-speed
to speed up the replay
--input-file-replay-speed=10
Capture gRPC requests on "127.0.0.1:35001", keep only requests whose method suffix is Time, and print them in the console
./grpcr --input-raw="127.0.0.1:35001" --output-stdout --include-filter-method-match=".*Time$"
Capture the gRPC request on "127.0.0.1:35001" and send it to the test topic of RocketMQ
./grpcr --input-raw="127.0.0.1:35001" --output-rocketmq-name-server="192.168.2.100:9876" --output-rocketmq-topic="test"
Get the gRPC request from RocketMQ, send it to "127.0.0.1:35001", and print it in the console
./grpcr --input-rocketmq-name-server="192.168.2.100:9876" --input-rocketmq-topic="test" --output-stdout --output-grpc="grpc://127.0.0.1 :35001"
{
"headers": {
":authority": "localhost:35001",
":method": "POST",
":path": "/SearchService/Search",
":scheme": "http",
"content-type": "application/grpc",
"te": "trailers",
"testkey1": "testvalue1",
"testkey2": "testvalue2",
"user-agent": "grpc-go/1.48.0"
},
"method": "/SearchService/Search",
"request": "{\"staffName\":\"zhangsan\",\"gender\":true,\"age\":405084}"
}
Set the log level Optional value: debug | info | warn | error
export SIMPLE_LOG_LEVEL=debug
This project uses google/gopacket and therefore depends on libpcap
inspired by fullstorydev/grpcurl and buger/goreplay