1

I am running Hyperledger fabric 2.0 Blockchain using script files to create the channel, Orderer and peers. I am using fabric-gateway-java:2.1.1 as the Java SDK and I am using a connection profile to connect to the Blockchain from the SDK, see below:

public static Gateway connect() throws Exception{
     // Load a file system based wallet for managing identities.
     Path walletPath = Paths.get("wallet");
     Wallet wallet = Wallets.newFileSystemWallet(walletPath);
     // load a CCP
     Path networkConfigPath = Paths.get("..", "..", "TestBlockchain", "organizations",
             "peerOrganizations", "org1.test.com", "connection-org1.yaml");

     Gateway.Builder builder = Gateway.createBuilder();
     builder.identity(wallet, "appUser").networkConfig(networkConfigPath).discovery(true);
     return builder.connect();
 };

My connection profile looks like this: Note: I have removed the certificates for this question

name: TestBlockchain-org1
version: 1.0.0
channels: testchannel
client:
  organization: Org1
  connection:
    timeout:
      peer:
        endorser: '300'
organizations:
  Org1:
    mspid: Org1MSP
    peers:
    - peer0.org1.test.com
    certificateAuthorities:
    - ca.org1.test.com
peers:
  peer0.org1.test.com:
    url: grpcs://localhost:7051
    tlsCACerts:
      pem: |
          -----BEGIN CERTIFICATE-----
          
          -----END CERTIFICATE-----
          
    grpcOptions:
      ssl-target-name-override: peer0.org1.test.com
      hostnameOverride: peer0.org1.test.com
      grpc.max_send_message_length: 9000000
      grpc.max_receive_message_length: 9000000
  peer1.org1.test.com:
    url: grpcs://localhost:7051
    tlsCACerts:
      pem: |
            -----BEGIN CERTIFICATE-----
          
          -----END CERTIFICATE-----
    
    grpcOptions:
      ssl-target-name-override: peer1.org1.test.com
      hostnameOverride: peer1.org1.test.com
      grpc.max_send_message_length: 9000000
      grpc.max_receive_message_length: 9000000
certificateAuthorities:
  ca.org1.test.com:
    url: https://localhost:7054
    caName: ca-org1
    tlsCACerts:
      pem: 
        - |
          -----BEGIN CERTIFICATE-----
          -----END CERTIFICATE-----
          
    httpOptions:
      verify: false

When I set the grpc.max_receive_message_length in the connection profile it doesn't seem to work when trying to receive messages from the Blockchain that are larger than 4GB

The error I keep getting is RESOURCE EXHAUSTED: Compressed gRPC message exceeds maximum size 4194304 4GB.

Question: Is there another way to increase this limit for the grpc in the connection profile or maybe the java code itself?

I have tried searching on the internet for a solution and there doesnt seem to be so hopefully someone can come to my rescue and help. Thanks in advance :)

4
  • most people would advise you don't use the blockchain to store the data but to store a reference to the data which is far smaller. Is there a legitimate need to store 4GB on-chain vs. off-chain? Commented Jul 22, 2021 at 12:28
  • Storing the data is fine, I wouldnt be pushing any data over 4GB up onto the Blockchain. Its just when I try query the Blockchain for some use cases I need to get more than 4GB back. Commented Jul 22, 2021 at 12:54
  • stackoverflow.com/questions/60522516/… see if this helps - theres a link within to a setting you can configure to increase the size Commented Jul 22, 2021 at 18:20
  • Eh. Is this really Gigabytes? I'm sending around 9 MB and the message looks like 'Message exceeds maximum size 4194304:9774649' Commented Jan 20, 2023 at 15:48

2 Answers 2

1

I was not able to solve the problem, although I did find a workaround. I ended up using the fabric Go SDK instead of the Java SDK as the Go SDK allows up to 100MB in grpc max message length by default which ultimately solved my problem.

Link to the Go SDK: https://github.com/hyperledger/fabric-sdk-go

However, the only downfall for the using the Go SDK is that the grpc timeout is set to 30 seconds by default.

I also found the transactions to and from my Hyperledger Fabric Blockchain were a lot faster when using the Go SDK rather than the Java SDK.

Sign up to request clarification or add additional context in comments.

1 Comment

Sad to hear this. We have NiFi Processors in Java connecting to Hyperledger Fabric. Go would not be an easy option here....
0

This disconnect between parameters accepted by Java, Python or Node.js Fabric SDKs is not nice. But in case of Java I've found the parameter which solved similar problem

grpc.NettyChannelBuilderOption.maxInboundMessageSize: 9000000

Also mentioned here Hyperledger Fabric 2.0 - gRPC message exceeds maximum size 4194304: 5947481

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.