gRPC message exceeds maximum size 4194304

Hello Damlers,

I’m trying to create a contract using the JSON api. In the project I’ve included a set of types that are relatively large resulting a 4MB dar file.

This is the result I get when trying to create a contract:

http://localhost:7575/v1/create

{
  "templateId": "DarDistribution:AcceptedDar",
  "payload": {
    "darOwner": "alice::1220f058ad95458add5a12a9b7381f53ee5135f9f36ce13217b3cf75105fa2cab8c7",
    "recipient": "alice::1220f058ad95458add5a12a9b7381f53ee5135f9f36ce13217b3cf75105fa2cab8c7",
    "hash": "1220f058ad95458add5a12a9b7381f53ee5135f9f36ce13217b3cf75105fa2cab8c7"
  }
}
{
    "errors": [
        "RESOURCE_EXHAUSTED: gRPC message exceeds maximum size 4194304: 8575058"
    ],
    "ledgerApiError": {
        "code": 8,
        "details": [],
        "message": "gRPC message exceeds maximum size 4194304: 8575058"
    },
    "status": 429
}

Thank you in advance.

See where package-max-inbound-message-size is set in the example JSON API configuration file; you’ll need to make a similar setting in your own config file.

Yes, I’ve already tried this.


    server {
        address = "localhost"
        port = 7576
    }
    ledger-api {
        address = "localhost"
        port = 6865
    }
    package-reload-interval = 10s
    max-inbound-message-size = 9194304
    package-max-inbound-message-size = 9194304
    max-template-id-cache-entries = 1000
    health-timeout-seconds = 10
}

The error seems to come from the underlying ledger not the JSON API. So you need to increase the max inbound size there.

1 Like

I’ve added the following command to my daml.yaml

scenario-service:
  grpc-max-message-size: 14194304

Is there any alternative?

That’s the scenario service not the ledger you’re running the JSON API against. Are you using daml sandbox?

I’m using daml start

You need to change the max message size as described in Static Configuration — Daml SDK 2.2.0 documentation.

Take a look at the sandbox docs for how you can pass a config file to sandbox.

Solved the problem by adding the following lines to daml.yaml:

json-api-options: 
  - --max-inbound-message-size=9000000
1 Like