dapr icon indicating copy to clipboard operation
dapr copied to clipboard

How to configure dapr gRpc max_receive_message_length?

Open drriguz opened this issue 3 years ago • 6 comments

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?

drriguz avatar Aug 06 '21 13:08 drriguz

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

drriguz avatar Aug 09 '21 03:08 drriguz

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

yaron2 avatar Aug 09 '21 16:08 yaron2

I'm closing this for now, will make sure this is added to either SDK docs or elsewhere.

yaron2 avatar Aug 09 '21 16:08 yaron2

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.

BhusanBibhuti avatar Feb 20 '22 13:02 BhusanBibhuti

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.

dapr-bot avatar Jun 22 '22 15:06 dapr-bot

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

@yaron2 Is there a java equivalent?

johnseed avatar Aug 02 '22 02:08 johnseed

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.

dapr-bot avatar Oct 01 '22 03:10 dapr-bot

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.

dapr-bot avatar Oct 08 '22 03:10 dapr-bot

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.

dapr-bot avatar Dec 07 '22 04:12 dapr-bot

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.

dapr-bot avatar Dec 14 '22 04:12 dapr-bot

I solved this by adding the GrpcChannelOptions in Startup.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 the MaxSendMessageSize but not the MaxReceiveMessageSize, 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

buynowdev avatar Jan 17 '23 01:01 buynowdev

I also ran into this recently @drriguz answer worked for me but we should add this into the dotnet sdk docs

alicejgibbons avatar Feb 06 '24 13:02 alicejgibbons