@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1785") public final class OkHttpChannelBuilder extends io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_FLOW_CONTROL_WINDOW |
| Modifier and Type | Method and Description |
|---|---|
OkHttpChannelBuilder |
connectionSpec(com.squareup.okhttp.ConnectionSpec connectionSpec)
For secure connection, provides a ConnectionSpec to specify Cipher suite and
TLS versions.
|
protected ManagedChannelBuilder<?> |
delegate() |
OkHttpChannelBuilder |
flowControlWindow(int flowControlWindow)
Sets the flow control window in bytes.
|
static OkHttpChannelBuilder |
forAddress(String host,
int port)
Creates a new builder for the given server host and port.
|
static OkHttpChannelBuilder |
forAddress(String host,
int port,
ChannelCredentials creds)
Creates a new builder with the given host and port.
|
static OkHttpChannelBuilder |
forTarget(String target)
Creates a new builder for the given target that will be resolved by
NameResolver. |
static OkHttpChannelBuilder |
forTarget(String target,
ChannelCredentials creds)
Creates a new builder for the given target that will be resolved by
NameResolver. |
OkHttpChannelBuilder |
hostnameVerifier(HostnameVerifier hostnameVerifier)
Set the hostname verifier to use when using TLS negotiation.
|
OkHttpChannelBuilder |
keepAliveTime(long keepAliveTime,
TimeUnit timeUnit) |
OkHttpChannelBuilder |
keepAliveTimeout(long keepAliveTimeout,
TimeUnit timeUnit) |
OkHttpChannelBuilder |
keepAliveWithoutCalls(boolean enable) |
OkHttpChannelBuilder |
maxInboundMessageSize(int max)
Sets the maximum message size allowed for a single gRPC frame.
|
OkHttpChannelBuilder |
maxInboundMetadataSize(int bytes)
Sets the maximum size of metadata allowed to be received.
|
OkHttpChannelBuilder |
negotiationType(NegotiationType type)
Deprecated.
use
usePlaintext() or useTransportSecurity() instead. |
OkHttpChannelBuilder |
scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
Provides a custom scheduled executor service.
|
OkHttpChannelBuilder |
socketFactory(SocketFactory socketFactory)
Override the default
SocketFactory used to create sockets. |
OkHttpChannelBuilder |
sslSocketFactory(SSLSocketFactory factory)
Override the default
SSLSocketFactory and enable TLS negotiation. |
OkHttpChannelBuilder |
tlsConnectionSpec(String[] tlsVersions,
String[] cipherSuites)
Sets the connection specification used for secure connections.
|
OkHttpChannelBuilder |
transportExecutor(Executor transportExecutor)
Override the default executor necessary for internal transport use.
|
OkHttpChannelBuilder |
usePlaintext()
Sets the negotiation type for the HTTP/2 connection to plaintext.
|
OkHttpChannelBuilder |
useTransportSecurity()
Sets the negotiation type for the HTTP/2 connection to TLS (this is the default).
|
build, compressorRegistry, decompressorRegistry, defaultLoadBalancingPolicy, defaultServiceConfig, directExecutor, disableRetry, disableServiceConfigLookUp, enableFullStreamDecompression, enableRetry, executor, idleTimeout, intercept, intercept, maxHedgedAttempts, maxRetryAttempts, maxTraceEvents, nameResolverFactory, offloadExecutor, overrideAuthority, perRpcBufferLimit, proxyDetector, retryBufferSize, setBinaryLog, thisT, toString, userAgentpublic static final int DEFAULT_FLOW_CONTROL_WINDOW
public static OkHttpChannelBuilder forAddress(String host, int port)
public static OkHttpChannelBuilder forAddress(String host, int port, ChannelCredentials creds)
public static OkHttpChannelBuilder forTarget(String target)
NameResolver.public static OkHttpChannelBuilder forTarget(String target, ChannelCredentials creds)
NameResolver.@Internal protected ManagedChannelBuilder<?> delegate()
delegate in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>public OkHttpChannelBuilder transportExecutor(@Nullable Executor transportExecutor)
The channel does not take ownership of the given executor. It is the caller' responsibility to shutdown the executor when appropriate.
public OkHttpChannelBuilder socketFactory(@Nullable SocketFactory socketFactory)
SocketFactory used to create sockets. If the socket factory is not
set or set to null, a default one will be used.@Deprecated public OkHttpChannelBuilder negotiationType(NegotiationType type)
usePlaintext() or useTransportSecurity() instead.If TLS is enabled a default SSLSocketFactory is created using the best
Provider available and is NOT based on
SSLSocketFactory.getDefault(). To more precisely control the TLS configuration call
sslSocketFactory to override the socket factory used.
Default: TLS
public OkHttpChannelBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit)
keepAliveTime in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>public OkHttpChannelBuilder keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit)
keepAliveTimeout in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>public OkHttpChannelBuilder flowControlWindow(int flowControlWindow)
DEFAULT_FLOW_CONTROL_WINDOW).public OkHttpChannelBuilder keepAliveWithoutCalls(boolean enable)
keepAliveWithoutCalls in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>keepAliveTime(long, TimeUnit)public OkHttpChannelBuilder sslSocketFactory(SSLSocketFactory factory)
SSLSocketFactory and enable TLS negotiation.public OkHttpChannelBuilder hostnameVerifier(@Nullable HostnameVerifier hostnameVerifier)
Be careful when setting a custom hostname verifier! By setting a non-null value, you are replacing all default verification behavior. If the hostname verifier you supply does not effectively supply the same checks, you may be removing the security assurances that TLS aims to provide.
This method should not be used to avoid hostname verification, even during testing, since
AbstractManagedChannelImplBuilder.overrideAuthority(java.lang.String) is a safer alternative as it does not disable any security checks.
OkHostnameVerifierpublic OkHttpChannelBuilder connectionSpec(com.squareup.okhttp.ConnectionSpec connectionSpec)
By default a modern, HTTP/2-compatible spec will be used.
This method is only used when building a secure connection. For plaintext
connection, use usePlaintext() instead.
IllegalArgumentException - If connectionSpec is not with TLSpublic OkHttpChannelBuilder tlsConnectionSpec(String[] tlsVersions, String[] cipherSuites)
By default a modern, HTTP/2-compatible spec will be used.
This method is only used when building a secure connection. For plaintext
connection, use usePlaintext() instead.
tlsVersions - List of tls versions.cipherSuites - List of cipher suites.public OkHttpChannelBuilder usePlaintext()
usePlaintext in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>public OkHttpChannelBuilder useTransportSecurity()
With TLS enabled, a default SSLSocketFactory is created using the best Provider available and is NOT based on SSLSocketFactory.getDefault(). To
more precisely control the TLS configuration call sslSocketFactory(SSLSocketFactory)
to override the socket factory used.
useTransportSecurity in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>public OkHttpChannelBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
It's an optional parameter. If the user has not provided a scheduled executor service when the channel is built, the builder will use a static cached thread pool.
public OkHttpChannelBuilder maxInboundMetadataSize(int bytes)
Integer.MAX_VALUE disables
the enforcement. Defaults to no limit (Integer.MAX_VALUE).
The implementation does not currently limit memory usage; this value is checked only after the metadata is decoded from the wire. It does prevent large metadata from being passed to the application.
maxInboundMetadataSize in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>bytes - the maximum size of received metadataIllegalArgumentException - if bytes is non-positivepublic OkHttpChannelBuilder maxInboundMessageSize(int max)
maxInboundMessageSize in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>