HyperLedger fabric java sdk

152 views Asked by At

I am using Hyperledger Fabric 1.4v, running one organisation with two peers(peer0,peer1) each running on separate vm in an native setup.Orderer also running on a separate vm. In a webclient, using java sdk the chaincodes are executed and each user is authenticated using fabric-ca. I am facing latency issue(takes more than a minute) when chaincode are executed through java sdk but it works fine when the chaincodes are executed through shell script.

 try {
                Wallet wallet = Wallet.createFileSystemWallet(walletPath);
                Gateway.Builder builder = Gateway.createBuilder();
                builder.identity(wallet, "admin").networkConfig(networkConfigPath).discovery(true);

                try (Gateway gateway = builder.connect()) {

                    Network network = gateway.getNetwork(channelName);
                    logger.info("ChannelName:::" + channelName);
                    Contract contract = network.getContract(chaincodeName);
                    logger.info("ChaincodeName:::" + chaincodeName);

                    result = contract.evaluateTransaction(chaincodeMethod);
                    logger.info("ChaincodeExecutor::::Result:::" + result);

                }

            } catch (Exception e) {
                logger.info("ChaincodeExecutor::::ERROR::" + e.getMessage());
                e.printStackTrace();
            }
1

There are 1 answers

1
kekomal On

Chaincode runs on its own docker container, which is launched by the peer. First time, if that container (for that chaincode version) has not been launched, it must be launched, so it takes its time.

Does the second request (on the same peer) take so much time? If it does, you must check your chaincode, specially rich queries (set indexes and improve queries). Network-related and hardware-related resources are important, too.

Your client's code does not contribute much to your question.