🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] > [github](https://github.com/kevwan/tproxy/blob/main/readme-cn.md) ## 概述 1. 分析 gRPC 连接何时连接、何时重连 2. 分析 MySQL 连接池,当前多少连接,连接的生命周期是什么策略 3. 也可以用来观察和分析任何 TCP 连接 **语法** ``` tproxy --help Usage of tproxy: -d duration the delay to relay packets -l string Local address to listen on (default "localhost") -p int Local port to listen on, default to pick a random port -q Quiet mode, only prints connection open/close and stats, default false -r string Remote address (host:port) to connect -s Enable statistics -t string The type of protocol, currently support grpc ``` **安装** ``` GOPROXY=https://goproxy.cn/,direct go install github.com/kevwan/tproxy@latest ``` ## 示例 ### 分析 gRPC 连接 ``` tproxy -p 8088 -r localhost:8081 -t grpc -d 100ms ``` 侦听在 localhost 和 8088 端口 重定向请求到 localhost:8081 识别数据包格式为 gRPC 数据包延迟100毫秒 ![](https://img.kancloud.cn/27/fe/27fe9dfea7a871dbf08f727e2dbd9a81_1080x1324.png) ### 分析 MySQL 连接 ``` tproxy -p 3307 -r localhost:3306 ``` ![](https://img.kancloud.cn/13/92/1392bb166b3c733676da82d740a004dc_1122x718.png)