尝试将链码用于测试网络时 HYPERLEDGER FABRIC 出错,但 运行 我的应用程序
Error at HYPERLEDGER FABRIC while trying to use the chaincode for the test network but running my application
我的问题是我在尝试将链代码用于测试网络时遇到错误,但 运行 宁我的应用程序而不是 fabric-samples/asset-transfer-basic 提供的应用程序-javascript .
我遵循的步骤是:
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.
我得到的错误如下:
--> 提交交易:InitLedger,函数在账本上创建初始资产集
2021-11-09T15:54:16.248Z - 错误:[交易]:错误:没有来自任何同行的有效回复。错误:
******** 未能 运行 应用程序:错误:没有来自任何对等方的有效响应。错误:
我的应用程序中的代码与文档中的代码完全相同:
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');
您在代码中禁用了对等点发现,通常,您在指定要连接的对等点时执行此操作,但由于您没有这样做 - SDK 客户端只是不知道它应该连接到哪些对等点connect 所以它连接到其中 none 个,得到 0 个响应并抛出错误。所以我从你的例子中改变了这一行:
discovery: { enabled: false, asLocalhost: true }
至:
discovery: { enabled: true, asLocalhost: true }
成功了。
我的问题是我在尝试将链代码用于测试网络时遇到错误,但 运行 宁我的应用程序而不是 fabric-samples/asset-transfer-basic 提供的应用程序-javascript .
我遵循的步骤是:
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.
我得到的错误如下:
--> 提交交易:InitLedger,函数在账本上创建初始资产集 2021-11-09T15:54:16.248Z - 错误:[交易]:错误:没有来自任何同行的有效回复。错误: ******** 未能 运行 应用程序:错误:没有来自任何对等方的有效响应。错误:
我的应用程序中的代码与文档中的代码完全相同:
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');
您在代码中禁用了对等点发现,通常,您在指定要连接的对等点时执行此操作,但由于您没有这样做 - SDK 客户端只是不知道它应该连接到哪些对等点connect 所以它连接到其中 none 个,得到 0 个响应并抛出错误。所以我从你的例子中改变了这一行:
discovery: { enabled: false, asLocalhost: true }
至:
discovery: { enabled: true, asLocalhost: true }
成功了。