<PackageReference Include="Grpc.Net.Client" Version="2.67.0" />

Grpc.Net.Client.GrpcChannelOptions

public sealed class GrpcChannelOptions
An options class for configuring a GrpcChannel.
public IList<ICompressionProvider> CompressionProviders { get; set; }

Gets or sets a collection of compression providers.

public ChannelCredentials Credentials { get; set; }

Gets or sets the credentials for the channel. This setting is used to set ChannelCredentials for a channel. Connection transport layer security (TLS) is determined by the address used to create the channel.

public bool DisableResolverServiceConfig { get; set; }

Gets or sets a value indicating whether resolving a service config from the Resolver is disabled. The default value is false.

A hint is provided to the resolver that it shouldn't fetch a service config. If a service config is returned by then resolver then it is ignored.

Note: Experimental API that can change or be removed without any prior notice.

public bool DisposeHttpClient { get; set; }

Gets or sets a value indicating whether the underlying HttpClient or HttpMessageHandler should be disposed when the GrpcChannel instance is disposed. The default value is false.

public HttpClient HttpClient { get; set; }

Gets or sets the HttpClient used by the channel to make HTTP calls.

public HttpMessageHandler HttpHandler { get; set; }

Gets or sets the HttpMessageHandler used by the channel to make HTTP calls.

public Version HttpVersion { get; set; }

Gets or sets the HTTP version to use when making gRPC calls.

When a Version is specified the value will be set on Version as gRPC calls are made. Changing this property allows the HTTP version of gRPC calls to be overridden.

A null value doesn't override the HTTP version of gRPC calls. Defaults to 2.0.

public HttpVersionPolicy? HttpVersionPolicy { get; set; }

Gets or sets the HTTP policy to use when making gRPC calls.

When a HttpVersionPolicy is specified the value will be set on VersionPolicy as gRPC calls are made. The policy determines how Version is interpreted when the final HTTP version is negotiated with the server. Changing this property allows the HTTP version of gRPC calls to be overridden.

A null value doesn't override the HTTP policy of gRPC calls. Defaults to RequestVersionExact.

public TimeSpan InitialReconnectBackoff { get; set; }

Gets or sets the time between the first and second connection attempts.

The reconnect backoff starts at an initial backoff and then exponentially increases between attempts, up to the maximum reconnect backoff. Reconnect backoff adds a jitter to randomize the backoff. This is done to avoid spikes of connection attempts.

Defaults to 1 second.

Note: Experimental API that can change or be removed without any prior notice.

public ILoggerFactory LoggerFactory { get; set; }

Gets or sets the logger factory used by the channel. If no value is specified then the channel attempts to resolve an ILoggerFactory from the ServiceProvider.

public int? MaxReceiveMessageSize { get; set; }

Gets or sets the maximum message size in bytes that can be received by the client. If the client receives a message that exceeds this limit, it throws an exception.

A null value removes the maximum message size limit. Defaults to 4,194,304 (4 MB).

public TimeSpan? MaxReconnectBackoff { get; set; }

Gets or sets the the maximum time between subsequent connection attempts.

The reconnect backoff starts at an initial backoff and then exponentially increases between attempts, up to the maximum reconnect backoff. Reconnect backoff adds a jitter to randomize the backoff. This is done to avoid spikes of connection attempts.

A null value removes the maximum reconnect backoff limit. The default value is 120 seconds.

Note: Experimental API that can change or be removed without any prior notice.

public int? MaxRetryAttempts { get; set; }

Gets or sets the maximum retry attempts. This value limits any retry and hedging attempt values specified in the service config.

Setting this value alone doesn't enable retries. Retries are enabled in the service config, which can be done using ServiceConfig.

A null value removes the maximum retry attempts limit. Defaults to 5.

Note: Experimental API that can change or be removed without any prior notice.

public long? MaxRetryBufferPerCallSize { get; set; }

Gets or sets the maximum buffer size in bytes that can be used to store sent messages when retrying or hedging calls. If the buffer limit is exceeded, then no more retry attempts are made and all hedging calls but one will be canceled. This limit is applied to one call.

Setting this value alone doesn't enable retries. Retries are enabled in the service config, which can be done using ServiceConfig.

A null value removes the maximum retry buffer size limit per call. Defaults to 1,048,576 (1 MB).

Note: Experimental API that can change or be removed without any prior notice.

public long? MaxRetryBufferSize { get; set; }

Gets or sets the maximum buffer size in bytes that can be used to store sent messages when retrying or hedging calls. If the buffer limit is exceeded, then no more retry attempts are made and all hedging calls but one will be canceled. This limit is applied across all calls made using the channel.

Setting this value alone doesn't enable retries. Retries are enabled in the service config, which can be done using ServiceConfig.

A null value removes the maximum retry buffer size limit. Defaults to 16,777,216 (16 MB).

Note: Experimental API that can change or be removed without any prior notice.

public int? MaxSendMessageSize { get; set; }

Gets or sets the maximum message size in bytes that can be sent from the client. Attempting to send a message that exceeds the configured maximum message size results in an exception.

A null value removes the maximum message size limit. Defaults to null.

public ServiceConfig ServiceConfig { get; set; }

Gets or sets the service config for a gRPC channel. A service config allows service owners to publish parameters to be automatically used by all clients of their service. A service config can also be specified by a client using this property.

Note: Experimental API that can change or be removed without any prior notice.

public IServiceProvider ServiceProvider { get; set; }

Gets or sets the IServiceProvider the channel uses to resolve types.

Note: Experimental API that can change or be removed without any prior notice.

public bool ThrowOperationCanceledOnCancellation { get; set; }

Gets or sets a value indicating whether clients will throw OperationCanceledException for a call when its CancellationToken is triggered or its Deadline is exceeded. The default value is false.

Note: Experimental API that can change or be removed without any prior notice.

public bool UnsafeUseInsecureChannelCallCredentials { get; set; }

Gets or sets a value indicating whether a gRPC call's CallCredentials are used by an insecure channel. The default value is false.

Note: Experimental API that can change or be removed without any prior notice.

Initializes a new instance of the GrpcChannelOptions class.