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());
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
});