libgrpc++: Enabling debug trace on Android

44 views
Skip to first unread message

David Collins

unread,
Nov 29, 2018, 7:18:16 PM11/29/18
to grpc.io
Hi all,

I have cross-compiled version 1.17.0 of the libgrpc++ library for the Android platform. When I link against this library in a test program for Android, the program runs successfully, but I can't view the extra logs and traces to debug.

Specifically, I have tried

    GRPC_VERBOSITY=debug GRPC_TRACE=api ./grpc-test

as well as variations on the above - e.g. using 'info' instead of 'debug' for the verbosity level. The program runs, but no trace info is displayed.

I am logging in to the Android console via `adb shell` to run the program. I have tried this on both a 32-bit ARM architecture (running Android 4.4) and an x86 emulator (need to check the Android version) - without success. When I compile the same program for my Linux desktop, I can view the debug trace without problem.

The libgrpc++ library is being compiled with debugging enabled, and I can actually debug the program using gdb + gdbserver. In some cases I would just prefer to debug using the 'trace' features of the library rather than gdb however.

My ultimate problem is that the library is failing to communicate with Google's TTS API. I am using `GoogleDefaultCredentials()` to retrieve credentials (and the GOOGLE_APPLICATION_CREDENTIALS environment variable is set correctly). When I try to invoke any method on the TextToSpeech::Stub, the request times out with the channel in state GRPC_CHANNEL_TRANSIENT_FAILURE. (I have used `set_deadline()` and `set_wait_for_ready(true)`).

The same program works as expected on Debian Linux. If I could view the trace on Android, it might help me to diagnose why it's failing there.

Can anyone think of a reason why the trace might not be activated on Android?

Incidentally, I have run a separate gRPC program on my Android device without problem - in this instance communicating with an insecure test server (using `InsecureChannelCredentials()`). Perhaps it's a SSL/TLS-related issue.

Michael Lumish

unread,
Nov 29, 2018, 8:06:19 PM11/29/18
to David Collins, grpc.io
Have you tried "GRPC_VERBOSITY=DEBUG"? Our environment variables are unfortunately case-sensitive with varying casing conventions

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/3599dfc6-bc6a-470e-a339-364117a95fae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Collins

unread,
Nov 30, 2018, 5:09:22 AM11/30/18
to grpc.io
Hi Michael. I have tried upper-case values for GRPC_VERBOSITY also - but still no trace info is displayed. I appreciate the suggestion.

David Collins

unread,
Dec 1, 2018, 8:08:16 AM12/1/18
to grpc.io
It turns out that tracing actually is being enabled. The issue is that - on the Android platform - gRPC uses Android's 'logcat' functionality instead of standard output. So the trace info is never sent to stdout: it has to be viewed using

    adb logcat GRPC

I am embarrassed I didn't think of this sooner [:blush:].

Diagnosing the connection issues didn't take long once the trace output was visible. It turns out that gRPC couldn't find the PEM file containing the SSL root certificates. Resolving this just required

    export GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=./roots.pem

April Kyle Nassi

unread,
Dec 1, 2018, 3:33:59 PM12/1/18
to da...@designtrail.net, grp...@googlegroups.com
Glad you found the issue, David! We would greatly appreciate it if you added this information to our docs; I'm sure others will have the same question at some point.




April Kyle Nassi, Program Manager

Google, Inc. | Open Source Strategy | Developer Relations

345 Spear Street, San Francisco, CA 94105

ana...@google.com | @thisisnotapril


 


Reply all
Reply to author
Forward
0 new messages