dapr
dapr copied to clipboard
How to configure dapr gRpc max_receive_message_length?
I'm using dapr binding to fetch azure blob,
await _daprClient.InvokeBindingAsync(
new BindingRequest("blob-storage", "get")
{
Metadata = {{"blobName", blogName}}
});
However, if the blob is larger than 4mb, it will result in error:
RpcException: Status(StatusCode="ResourceExhausted", Detail="Received message exceeds the maximum configured message size.")
Dapr.Client.DaprClientGrpc.MakeInvokeBindingRequestAsync(string name, string operation, ByteString data, IReadOnlyDictionary<string, string> metadata, CancellationToken cancellationToken)
DaprException: Binding operation failed: the Dapr endpoint indicated a failure. See InnerException for details.
Dapr.Client.DaprClientGrpc.MakeInvokeBindingRequestAsync(string name, string operation, ByteString data, IReadOnlyDictionary<string, string> metadata, CancellationToken cancellationToken)
Even if the --dapr-http-max-request-size
is set, it seems that the gRPC option max_receive_message_length
need to be set to a higher value. So how can we customize it?
I solved this by adding the GrpcChannelOptions
in Startup.cs
:
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddNewtonsoftJson()
.AddDapr(builder => builder.UseGrpcChannelOptions(new GrpcChannelOptions()
{
MaxReceiveMessageSize = 30 * 1024 * 1024,
MaxSendMessageSize = 30 * 1024 * 1024
}));
}
I guess the max_receive_message_length
option only changes the MaxSendMessageSize
but not the MaxReceiveMessageSize
, but currently I don't have much time to dig into it.
It would be nice if Dapr team can add more into the document :p
You're right, since the Dapr SDKs (mostly) use gRPC clients, the body size setting needs to be set on both Dapr and the gRPC client used by the SDK.
/cc @rynowak
I'm closing this for now, will make sure this is added to either SDK docs or elsewhere.
It did not work for me. dapr-http-max-request-size is set to 16 MB and also set to the same for UseGrpcChannelOptions. Please advise further.
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
I solved this by adding the
GrpcChannelOptions
inStartup.cs
:public void ConfigureServices(IServiceCollection services) { services.AddControllers() .AddNewtonsoftJson() .AddDapr(builder => builder.UseGrpcChannelOptions(new GrpcChannelOptions() { MaxReceiveMessageSize = 30 * 1024 * 1024, MaxSendMessageSize = 30 * 1024 * 1024 })); }
I guess the
max_receive_message_length
option only changes theMaxSendMessageSize
but not theMaxReceiveMessageSize
, but currently I don't have much time to dig into it.It would be nice if Dapr team can add more into the document :p
@yaron2 Is there a java equivalent?
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.
I solved this by adding the
GrpcChannelOptions
inStartup.cs
:我通过在Startup.cs中添加GrpcChannelOptions解决了这个问题。public void ConfigureServices(IServiceCollection services) { services.AddControllers() .AddNewtonsoftJson() .AddDapr(builder => builder.UseGrpcChannelOptions(new GrpcChannelOptions() { MaxReceiveMessageSize = 30 * 1024 * 1024, MaxSendMessageSize = 30 * 1024 * 1024 })); }
I guess the
max_receive_message_length
option only changes theMaxSendMessageSize
but not theMaxReceiveMessageSize
, but currently I don't have much time to dig into it.我猜max_receive_message_length选项只改变了MaxSendMessageSize,而没有改变MaxReceiveMessageSize,但目前我没有太多的时间去研究。It would be nice if Dapr team can add more into the document :p如果Dapr团队能在文件中加入更多的内容就更好了:p
I can't find how to configure the location of this UseGrpcChannelOptions
I also ran into this recently @drriguz answer worked for me but we should add this into the dotnet sdk docs