Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle RESOURCE EXHAUSTED error in API calls

Tags:

daml

I’m using the Java Ledger Bindings to get packages from the ledger via the Package service and am getting the following error:

RESOURCE_EXHAUSTED: gRPC message exceeds maximum size

My application is based on the Ping-Pong example application and the daml model has about 300+ daml files.

The exception occurs around the following code block:

DamlLedgerClient client = DamlLedgerClient.forHostWithLedgerIdDiscovery(host, port, Optional.empty());
client.connect();
PackageClient packageService = client.getPackageClient();
Flowable<String> packagesIds = packageService.listPackages();
like image 489
dsun Avatar asked Jan 22 '19 21:01

dsun


1 Answers

The message size is limited by the ManagedChannel used to connect to the gRPC server. To increase it, you have to construct and configure the ManagedChannel for gRPC yourself and pass it to the constructor of DamlLedgerClient.

ManagedChannel channel =
    ManagedChannelBuilder
    .forAddress(host,port)
    .usePlaintext()
    .maxInboundMessageSize(9999999)
    .build();
DamlLedgerClient client = new DamlLedgerClient(Optional.empty(), channel);
like image 77
bame Avatar answered Jan 03 '23 08:01

bame