简体   繁体   English

超级账本结构 Java SDK grpc maxInboundMessageSize

[英]Hyperledger Fabric Java SDK grpc maxInboundMessageSize

I am running Hyperledger fabric 2.0 Blockchain using script files to create the channel, Orderer and peers.我正在使用脚本文件运行 Hyperledger fabric 2.0 Blockchain 来创建通道、订购者和对等点。 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:我正在使用 fabric-gateway-java:2.1.1 作为 Java SDK 并且我正在使用连接配置文件从 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();
 };

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当我在连接配置文件中设置 grpc.max_receive_message_length 时,它似乎在尝试从区块链接收大于 4GB 的消息时不起作用

The error I keep getting is RESOURCE EXHAUSTED: Compressed gRPC message exceeds maximum size 4194304 4GB.我不断收到的错误是资源耗尽:压缩的 gRPC 消息超过最大大小 4194304 4GB。

Question: Is there another way to increase this limit for the grpc in the connection profile or maybe the java code itself?问题:是否有另一种方法可以在连接配置文件或 java 代码本身中增加 grpc 的此限制?

I have tried searching on the inte.net for a solution and there doesnt seem to be so hopefully someone can come to my rescue and help.我曾尝试在 inte.net 上搜索解决方案,但似乎并没有希望有人能来拯救我并提供帮助。 Thanks in advance:)提前致谢:)

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.我最终使用结构 Go SDK 而不是 Java SDK 作为 Go SDK 允许 grpc 最大消息长度默认为 100MB,这最终解决了我的问题。

Link to the Go SDK: https://github.com/hyperledger/fabric-sdk-go 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.然而,使用 Go SDK 的唯一缺点是 grpc 超时默认设置为 30 秒。

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.我还发现使用 Go SDK 而不是 Java SDK 时,进出我的 Hyperledger Fabric 区块链的交易要快得多。

This disconnect between parameters accepted by Java, Python or Node.js Fabric SDKs is not nice. Java、Python 或 Node.js Fabric SDK 接受的参数之间的这种断开并不好。 But in case of Java I've found the parameter which solved similar problem但在 Java 的情况下,我找到了解决类似问题的参数

grpc.NettyChannelBuilderOption.maxInboundMessageSize: 9000000

Also mentioned here Hyperledger Fabric 2.0 - gRPC message exceeds maximum size 4194304: 5947481此处还提到Hyperledger Fabric 2.0 - gRPC 消息超出最大大小 4194304: 5947481

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM