Skip to content

Chronicle gRPC message size configuration

Increase a Chronicle .NET client’s gRPC message limit when a request or response exceeds its configured size. Client send and receive limits default to 100 MiB each; the kernel has separate limits, so changing the client alone may not let a large message through.

The .NET client’s MaxReceiveMessageSize and MaxSendMessageSize each default to 104,857,600 bytes (100 MiB). They limit individual messages, not the total data transferred over a connection.

A request must fit both the client’s send limit and the kernel’s receive limit. A response must fit the kernel’s send limit, if set, and the client’s receive limit.

Set the limits in ChronicleOptions before creating the client. This example raises both client limits to 200 MiB:

public static class GrpcMessageSizeConfiguration
{
public static ChronicleClient Create()
{
var options = new ChronicleOptions
{
ConnectionString = "chronicle://localhost:35000",
MaxReceiveMessageSize = 200 * 1024 * 1024, // 200 MB
MaxSendMessageSize = 200 * 1024 * 1024 // 200 MB
};
return new ChronicleClient(options);
}
}

View C# snippet source on GitHub

For a hosted .NET application, set the same properties under Cratis:Chronicle in appsettings.json. These settings are bound when you register Chronicle with AddCratisChronicle:

{
"Cratis": {
"Chronicle": {
"ConnectionString": "chronicle://localhost:35000",
"MaxReceiveMessageSize": 209715200,
"MaxSendMessageSize": 209715200
}
}
}

To change the client’s limits through its environment, use the following keys. .NET maps __ to nested configuration sections:

Terminal window
Cratis__Chronicle__MaxReceiveMessageSize=209715200
Cratis__Chronicle__MaxSendMessageSize=209715200

The kernel’s receive limit defaults to 100 MiB. If you increase the client’s send limit to 200 MiB, also increase the kernel’s receive limit before sending messages that large.

Set these values in the kernel’s configuration, not the application’s client configuration:

{
"maxReceiveMessageSize": 209715200,
"maxSendMessageSize": 209715200
}
Terminal window
Cratis__Chronicle__MaxReceiveMessageSize=209715200
Cratis__Chronicle__MaxSendMessageSize=209715200

The kernel’s send size is unlimited unless you set it. The environment-variable names match the client’s names, but must be applied to the kernel process to change its limits. See Root Properties.

A size-limit failure can appear as:

Status(StatusCode="ResourceExhausted", Detail="Received message exceeds the maximum configured message size.")

Identify which process is receiving the message before changing a setting. For a response arriving at your application, check the client’s MaxReceiveMessageSize. For an append request arriving at the kernel, check the kernel’s maxReceiveMessageSize. Reduce the message size or raise that receiver’s limit, then check the sender’s limit too.

Choose an explicit bound that fits the payloads you expect and the memory available to both processes. Raising a limit allows larger messages to be held in memory; it does not make them cheaper to send or process. Splitting a large event batch can avoid increasing the limit.

Once you choose a size, check both ends of the transfer using Server limits. See Client Configuration if you need to change how the application supplies its options.

Setting either property to null removes that client-side limit. It does not restore gRPC’s default receive limit. Keep an explicit bound unless you intend to allow messages without a client-side size limit.

The .NET snippet below has stale comments saying null uses a 4 MB default. Those comments are incorrect: each assignment removes its corresponding client-side limit.

public static class GrpcMessageSizeNullValues
{
public static ChronicleOptions Create() =>
new()
{
MaxReceiveMessageSize = null, // Uses gRPC default of 4 MB - not recommended
MaxSendMessageSize = null // Uses gRPC default of 4 MB - not recommended
};
}

View C# snippet source on GitHub