Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting `Error: 8 RESOURCE_EXHAUSTED: Received message larger than max (15217288 vs. 4194304)` in Node.js gRPC client

How to increase max message size for Node.js gRPC client?

We use grpc, grpc-tools and protobufjs npm-packages:

  const packageDefinitions = loader.loadSync(PROTO_PATH, { includeDirs: [__dirname], longs: String, arrays: true });
  const packageObject = grpc.loadPackageDefinition(packageDefinitions);
  const client = new packageObject.Service(serviceAddress, grpc.credentials.createInsecure());
like image 995
razon Avatar asked Oct 15 '25 05:10

razon


1 Answers

For gRPC client and server we could specify gRPC params. For example, set the max messages size to 100 Mb:

Client

  const client = new packageObject.Service(serviceAddress, grpc.credentials.createInsecure(), {
    "grpc.max_receive_message_length": 1024 * 1024 * 100,
    "grpc.max_send_message_length": 1024 * 1024 * 100
  });

Server

  const server = new grpc.Server({
    "grpc.max_receive_message_length": 1024 * 1024 * 100,
    "grpc.max_send_message_length": 1024 * 1024 * 100
  });
like image 160
razon Avatar answered Oct 17 '25 21:10

razon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!