Unable to proxy gRPC calls using Charles

Viewed 361

I'm unable to (SSL) proxy any gRPC calls from my Android app using Charles 4.6.2. The request always times out on Received response header. Waiting for response body. Interestingly, I can see both request and response content (body), but the client still fails with DEADLINE_EXCEEDED error code. I'm guessing that something fails on the side of Charles when confirming the received response, because DEADLINE_EXCEEDED can happen even on a successful response. Disabling SSL proxying works for some reason though.

This is a sample log from the Charles debug console:

22:42:03    FINE     com.xk72.proxy.http.HttpProxyHandler                  Establishing HTTP/2 channel to CONNECT https://server.endpoint
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] CLIENT settings 0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] SERVER frame: SETTINGS 0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] SERVER settings 0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] CLIENT frame: SETTINGS 0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] SERVER settings 0 ack
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] CLIENT frame: SETTINGS 0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] SERVER window update for 0 268369921
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] CLIENT frame: WINDOW_UPDATE 0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] CLIENT headers 3
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Parsed  #307075206 [server.endpoint] CLIENT header 3 'POST https://server.endpoint/server.endpoint/MyRpcCall HTTP/2.0'
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] CLIENT settings 0 ack
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.StreamHandler  #307075206 [server.endpoint] stream 3 starting
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] SERVER frame: SETTINGS 0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http.HttpProxyHandler                  Received request POST /server.endpoint/MyRpcCall HTTP/2.0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] CLIENT data stream: 3 size: 107 END
2021/11/11 22:42:03 FINE     com.xk72.proxy.http.ProxyHttp                         Sending request POST /server.endpoint/MyRpcCall HTTP/2.0 to com.xk72.proxy.http2.v@9e9d902
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] SERVER frame: HEADERS 3
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] SERVER frame: DATA 3 size: 107 END
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] SERVER headers 3
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Parsed  #307075206 [server.endpoint] SERVER header 3 'HTTP/2.0 200'
2021/11/11 22:42:03 FINE     com.xk72.proxy.http.ProxyHttp                         Received response HTTP/2.0 200 for request POST /server.endpoint/MyRpcCall HTTP/2.0
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] SERVER data stream: 3 size: 229
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Receive #307075206 [server.endpoint] SERVER headers 3 END
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   Parsed  #307075206 [server.endpoint] SERVER header 3 '<empty>'
2021/11/11 22:42:03 FINE     com.xk72.proxy.http2.Frame                            Sending #307075206 [server.endpoint] CLIENT frame: HEADERS 3
2021/11/11 22:42:03 INFO     com.xk72.proxy.http2.Http2ProxyHandler.FrameHandler   #307075206 [server.endpoint] SERVER frame handler runtime error
2021/11/11 22:42:03 java.lang.IllegalStateException
2021/11/11 22:42:03     at com.xk72.proxy.http2.f.a(Unknown Source)
2021/11/11 22:42:03     at com.xk72.proxy.http2.A.a(Unknown Source)
2021/11/11 22:42:03     at com.xk72.proxy.http2.q.run(Unknown Source)
2021/11/11 22:42:03     at com.xk72.util.d.run(Unknown Source)
2021/11/11 22:42:03     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
2021/11/11 22:42:03     at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
2021/11/11 22:42:03     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
2021/11/11 22:42:03     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
2021/11/11 22:42:03     at java.base/java.lang.Thread.run(Unknown Source)

What's also interesting is that the message content log contains 3 empty next message lines before printing the actual message. My guess is that it is due to the length prefix, but I'm not sure.

>--------------------------------next message--------------------------------<
>--------------------------------next message--------------------------------<
>--------------------------------next message--------------------------------<
>--------------------------------next message--------------------------------<
field: "test"
1 Answers

The Mediator is a Cross-platform GUI gRPC debugging proxy like Charles but design for gRPC.

You can dump all gRPC requests without any configuration.

Mediator can render the binary message into a JSON tree, when you have the API schema, after Mediator v1.4.1 you can configure API schema by Server Reflection, proto Roots or file descriptors.

It support decode gRPC/TLS after 1.4.0 release, but you should download and install the Mediator Root Certificate to your device like Charles do.

Related