Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
src/main/ | H | 25-Apr-2025 | - | 345 | 228 | |
README.md | H A D | 25-Apr-2025 | 12.6 KiB | 239 | 201 | |
build.gradle | H A D | 25-Apr-2025 | 2.2 KiB | 77 | 63 | |
pom.xml | H A D | 25-Apr-2025 | 3.9 KiB | 124 | 116 | |
settings.gradle | H A D | 25-Apr-2025 | 35 | 2 | 1 |
README.md
1# gRPC Debug Example 2 3The debug example uses a Hello World style server whose response includes its 4hostname. It demonstrates usage of the AdminInterface and the grpcdebug 5commandline tool. 6 7The example requires grpc-java to already be built. You are strongly encouraged 8to check out a git release tag, since there will already be a build of grpc 9available. Otherwise, you must follow [COMPILING](../../COMPILING.md). 10 11### Build the example 12 131. Optional: Build the hello-world-debug example client. 14 See [the examples README](../README.md) 15 162. Build the debuggable server and client. From the 17 `grpc-java/examples/examples-debug` directory run: 18 19```bash 20$ ../gradlew installDist 21``` 22 23This creates the 24scripts `build/install/debug/bin/hostname-debuggable-server/bin/hostname-debuggable-server` 25that 26runs the example. 27 28To run the debug example, run: 29 30```bash 31$ ./build/install/debug/bin/hostname-debuggable-server/bin/hostname-debuggable-server 32``` 33 34And in a different terminal window run the client. 35 36Note: You can use the standard hello-world client with no debugging enabled and 37still see results on the server. However, if you want to get debug information 38about the client you need to run the hello-world-debuggable client. 39 40Simple client 41 42```bash 43$ ../build/install/examples/bin/hello-world-client 44``` 45 46debug enabled client 47 48```bash 49$ ./build/install/examples-debug/bin/hello-world-debuggable-client 50``` 51 52### Maven 53 54If you prefer to use Maven: 55 561. Build the hello-world example client. See [the examples README](../README.md) 57 582. Run in this directory: 59 60```bash 61$ mvn verify 62$ # Run the server (from the examples-debug directory) 63$ mvn exec:java -Dexec.mainClass=io.grpc.examples.debug.HostnameServer 64$ # In another terminal run the client (from the examples directory) 65$ cd .. 66$ mvn exec:java -Dexec.mainClass=io.grpc.examples.helloworld.HelloWorldClient 67``` 68 69## Using grpcdebug 70 71grpcdebug is a tool that has been created to access the metrics from the 72channelz and health services. 73 74### Installing the grpcdebug tool 75 76The source code is located in a github project 77[grpc-ecosystem/grpcdebug](https://github.com/grpc-ecosystem/grpcdebug). You 78can either download [the latest built version] 79(https://github.com/grpc-ecosystem/grpcdebug/releases/latest) (recommended) or 80follow the README.md to build it yourself. 81 82### Running the grpcdebug tool 83#### Usage 84`grpcdebug <target address> [flags] channelz <command> [argument]` 85 86 87| Command | Argument | Description | 88|:-----------|:--------------------:|:--------------------------------------------------| 89| channel | \<channel id or URL> | Display channel states in a human readable way. | 90| channels | | Lists client channels for the target application. | 91| server | \<server ID> | Displays server state in a human readable way. | 92| servers | | Lists servers in a human readable way. | 93| socket | \<socket ID> | Displays socket states in a human readable way. | 94| subchannel | \<id> | Display subchannel states in human readable way. | 95 96Generally, you will start with either `servers` or `channels` and then work down 97to the details 98<br><br> 99 100#### Getting overall server info 101```bash 102bin/grpcdebug/grpcdebug localhost:50051 channelz servers 103``` 104This will show you the server ids with their activity 105```text 106Server ID Listen Addresses Calls(Started/Succeeded/Failed) Last Call Started 1072 [[::]:50051] 38/34/3 now 108``` 109<br> 110 111#### Getting details for a service 112```bash 113bin/grpcdebug/grpcdebug localhost:50051 channelz server 2 114``` 115 116The output will include more communication details and will show socket ids for 117currently connected clients 118 119```text 120Server Id: 2 121Listen Addresses: [[::]:50051] 122Calls Started: 33 123Calls Succeeded: 29 124Calls Failed: 3 125Last Call Started: now 126--- 127Socket ID Local->Remote Streams(Started/Succeeded/Failed) Messages(Sent/Received) 12819 [::1]:50051->[::1]:39834 4/3/0 3/4 129``` 130 131#### Displaying detailed info for a server side connection (socket) 132 133```bash 134bin/grpcdebug/grpcdebug localhost:50051 channelz socket 19 135``` 136 137This will show a lot of gRPC internal information 138 139```text 140Socket ID: 19 141Address: [::1]:50051->[::1]:50094 142Streams Started: 1 143Streams Succeeded: 0 144Streams Failed: 0 145Messages Sent: 0 146Messages Received: 1 147Keep Alives Sent: 0 148Last Local Stream Created: 149Last Remote Stream Created: now 150Last Message Sent Created: 151Last Message Received Created: now 152Local Flow Control Window: 65535 153Remote Flow Control Window: 1048569 154--- 155Socket Options Name Value 156SO_LINGER [type.googleapis.com/grpc.channelz.v1.SocketOptionLinger]:{} 157io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#TCP_CORK false 158WRITE_BUFFER_HIGH_WATER_MARK 65536 159WRITE_BUFFER_LOW_WATER_MARK 32768 160IP_TOS 0 161io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#TCP_KEEPCNT 9 162SINGLE_EVENTEXECUTOR_PER_GROUP true 163SO_SNDBUF 2626560 164io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#TCP_NOTSENT_LOWAT 0 165WRITE_BUFFER_WATER_MARK WriteBufferWaterMark(low: 32768, high: 65536) 166TCP_NODELAY true 167SO_RCVBUF 131072 168io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#SO_BUSY_POLL 0 169IP_TRANSPARENT false 170SO_KEEPALIVE true 171io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#TCP_QUICKACK false 172ALLOCATOR PooledByteBufAllocator(directByDefault: true) 173TCP_FASTOPEN_CONNECT false 174MESSAGE_SIZE_ESTIMATOR io.grpc.netty.shaded.io.netty.channel.DefaultMessageSizeEstimator@48d475b6 175WRITE_SPIN_COUNT 16 176SO_REUSEADDR true 177CONNECT_TIMEOUT_MILLIS 30000 178ALLOW_HALF_CLOSURE false 179io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#EPOLL_MODE EDGE_TRIGGERED 180MAX_MESSAGES_PER_READ 16 181io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#TCP_KEEPIDLE 7200 182AUTO_CLOSE true 183io.grpc.netty.shaded.io.netty.channel.epoll.EpollChannelOption#TCP_KEEPINTVL 75 184MAX_MESSAGES_PER_WRITE 2147483647 185AUTO_READ true 186TCP_MD5SIG null 187RCVBUF_ALLOCATOR io.grpc.netty.shaded.io.netty.channel.AdaptiveRecvByteBufAllocator@360691a0 188``` 189#### Displaying the list of gRPC client channels 190Command 191```bash 192bin/grpcdebug/grpcdebug localhost:50051 channelz channels 193``` 194Output 195```text 196Channel ID Target State Calls(Started/Succeeded/Failed) Created Time 1971 localhost:50051 READY 34/34/0 1983 localhost:50051 READY 16/16/0 199``` 200Note: If you have a simple server that doesn't use gRPC clients to contact other 201servers, then this table will be empty. 202 203#### Displaying details of a gRPC client channel 204Command 205```bash 206bin/grpcdebug/grpcdebug localhost:50051 channelz channel 3 207``` 208Output 209```text 210Channel ID: 3 211Target: localhost:50051 212State: READY 213Calls Started: 16 214Calls Succeeded: 16 215Calls Failed: 0 216Created Time: 217--- 218Subchannel ID Target State Calls(Started/Succeeded/Failed) CreatedTime 21910 [[[localhost/127.0.0.1:50051]/{}], [[localhost/0:0 READY 16/16/0 220``` 221 222#### Displaying details of a gRPC client subchannel 223Command 224```bash 225bin/grpcdebug/grpcdebug localhost:50051 channelz subchannel 10 226``` 227Output 228```text 229Subchannel ID: 10 230Target: [[[localhost/127.0.0.1:50051]/{}], [[localhost/0:0:0:0:0:0:0:1:50051]/{}]] 231State: READY 232Calls Started: 16 233Calls Succeeded: 16 234Calls Failed: 0 235Created Time: 236--- 237Socket ID Local->Remote Streams(Started/Succeeded/Failed) Messages(Sent/Received) 23811 127.0.0.1:48536->127.0.0.1:50051 16/16/0 12/12 239```