简体   繁体   English

尝试将链码用于测试网络但运行我的应用程序时,HYPERLEDGER FABRIC 出错

[英]Error at HYPERLEDGER FABRIC while trying to use the chaincode for the test network but running my application

My problem is that i get an Error while trying to use the chaincode for the test-network but running my application instead of the application-javascript provided at fabric-samples/asset-transfer-basic.我的问题是我在尝试将链码用于测试网络但运行我的应用程序而不是在 fabric-samples/asset-transfer-basic 中提供的 application-javascript 时遇到错误。

The steps that I follow are:我遵循的步骤是:

1.  ./network.sh up createChannel -c mychannel -ca
2.  ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ -ccl javascript
3.  run my application thats is exaclty same with the one provided at docs (fabric-samples/asset-transfer-basic) to InitLedger and they query or update it.

The error I get is the following:我得到的错误如下:

--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger 2021-11-09T15:54:16.248Z - error: [Transaction]: Error: No valid responses from any peers. --> 提交交易:InitLedger,函数在分类账上创建初始资产集 2021-11-09T15:54:16.248Z - 错误:[交易]:错误:没有来自任何对等方的有效响应。 Errors: ******** FAILED to run the application: Error: No valid responses from any peers.错误:******** 无法运行应用程序:错误:没有来自任何对等方的有效响应。 Errors:错误:

The code in my application is exactly the same as the one at docs:我的应用程序中的代码与文档中的代码完全相同:

const ccp = buildCCPOrg1();
const caClient = buildCAClient(FabricCAServices, ccp, 'ca.org1.example.com');

const wallet = await buildWallet(Wallets, walletPath);

await enrollAdmin(caClient, wallet, mspOrg1);
await registerAndEnrollUser(caClient, wallet, mspOrg1, org1UserId, 'org1.department1');

const gateway = new Gateway();

await gateway.connect(ccp, {
    wallet,
    identity: org1UserId,
    discovery: { enabled: false, asLocalhost: true } // using asLocalhost as this gateway is using a fabric network deployed locally
});

const network = await gateway.getNetwork(channelName);
const contract = network.getContract(chaincodeName);
await contract.submitTransaction('InitLedger');


You have peer discovery disabled in your code, usually, you do it when you specify peers you want to connect to but since you don't do it - the SDK client just didn't know to what peers it should connect so it connected to none of them, got 0 responses and threw an error.您在代码中禁用了对等点发现,通常,您在指定要连接的对等点时执行此操作,但由于您不这样做 - SDK 客户端只是不知道它应该连接到哪些对等点,因此它连接到他们都没有,得到 0 个响应并抛出错误。 So I changed this line from your example:所以我从你的例子中改变了这一行:

discovery: { enabled: false, asLocalhost: true }

to:到:

discovery: { enabled: true, asLocalhost: true }

And it worked.它奏效了。

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

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