当前位置: 首页 > 知识库问答 >
问题:

Hyperledger Fabric Java SDK grpc maxInboundMessageSize

阙新觉
2023-03-14

我运行Hyperledger织物2.0区块链,使用脚本文件来创建通道、订单器和对等体。我使用织物网关java: 2.1.1作为JavaSDK,我使用连接配置文件从SDK连接到区块链,见下文:

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

我的连接配置文件看起来像这样:注意:我已经删除了此问题的证书

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

当我设置grpc时。连接配置文件中的最大接收消息长度当试图从区块链接收大于4GB的消息时,它似乎不起作用

我一直得到的错误是资源耗尽:压缩的gRPC消息超过最大大小4194304 4GB。

问题:有没有其他方法可以增加连接配置文件中grpc的限制,或者java代码本身的限制?

我曾尝试在互联网上搜索解决方案,但似乎没有那么希望有人能来帮助我。提前感谢:)

共有1个答案

尹光辉
2023-03-14

我无法解决这个问题,尽管我确实找到了一个解决方案。我最终使用了结构围棋SDK而不是JavaSDK,因为围棋SDK默认允许高达100MB的grpc最大消息长度,这最终解决了我的问题。

Go SDK的链接:https://github.com/hyperledger/fabric-sdk-go

然而,使用Go SDK的唯一缺点是默认情况下grpc超时设置为30秒。

我还发现,当使用Go SDK而不是Java SDK时,与Hyperledger Fabric区块链之间的交易速度要快得多。

 类似资料:

相关问答

相关文章

相关阅读