grpc-java/cronet
Kun Zhang c528df8ae8
core: add internal Subchannel.asChannel() (#4950)
Returns a Channel that allows a LoadBalancer to make auxiliary RPCs on already-established application connections. We need this to implement client-side health-checking (#4932)

See comments on the API for its semantics.

Notable changes:

- Transports are modified to use InUseStateAggregator so that they can exclude RPCs made on Subchannel.asChannel() when reporting in-use state for idle mode.
- OobChannel shares the same Executor as Subchannel.asChannel(). Because the latter is not a ManagedChannel and doesn't have life-cycle, thus can't determine when to return the Executor to a pool, the Executor is now returned only when ManagedChannelImpl is terminated.
2018-10-15 15:39:21 -07:00
..
src core: add internal Subchannel.asChannel() (#4950) 2018-10-15 15:39:21 -07:00
.gitignore cronet: add build.gradle and script for Cronet deps 2018-01-16 09:16:04 -08:00
README.md cronet: use Cronet from Google's Maven repository (#4531) 2018-06-04 20:16:02 -07:00
build.gradle Start 1.17.0 development cycle 2018-10-11 09:29:23 -07:00
proguard-rules.pro cronet: add build.gradle and script for Cronet deps 2018-01-16 09:16:04 -08:00

README.md

gRPC Cronet Transport

EXPERIMENTAL: gRPC's Cronet transport is an experimental API, and is not yet integrated with our build system. Using Cronet with gRPC requires manually integrating the gRPC code in this directory into your Android application.

This code enables using the Chromium networking stack (Cronet) as the transport layer for gRPC on Android. This lets your Android app make RPCs using the same networking stack as used in the Chrome browser.

Some advantages of using Cronet with gRPC:

  • Bundles an OpenSSL implementation, enabling TLS connections even on older versions of Android without additional configuration
  • Robust to Android network connectivity changes
  • Support for QUIC

Cronet jars are available on Google's Maven repository. See the example app at https://github.com/GoogleChrome/cronet-sample/blob/master/README.md. To use Cronet with gRPC, you will need to copy the gRPC source files contained in this directory into your application's code, as we do not currently provide a grpc-cronet dependency.

To use Cronet, you must have the ACCESS_NETWORK_STATE permission set in AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Once the above steps are completed, you can create a gRPC Cronet channel as follows:

import io.grpc.cronet.CronetChannelBuilder;
import org.chromium.net.ExperimentalCronetEngine;

...

ExperimentalCronetEngine engine =
    new ExperimentalCronetEngine.Builder(context /* Android Context */).build();
ManagedChannel channel = CronetChannelBuilder.forAddress("localhost", 8080, engine).build();