node.js - 为 IBM Block chain Hyperledger Fabric 运行enrollAdmin.js 时遇到错误
问题描述
我正在遵循 GitHub 上的教程,使用 IBM Blockchain(hyperledger 结构,我按照此处的步骤进行云部署:https ://github.com/IBM/evote 唯一的变化是我使用了 Hyperledger 结构 v2。 2、node.js v 15.4.0 在第 6 步“运行应用程序”中,当我尝试运行 nodeenrollAdmin.js 命令时收到错误消息。我在终端中收到的错误消息如下:
2021-04-22T08:57:53.453Z - error: [FabricCAClientService.js]: Failed to enroll app-admin, error:%o message=Calling enroll endpoint failed, CONNECTION Timeout, stack=Error: Calling enroll endpoint failed, CONNECTION Timeout
at TLSSocket.<anonymous> (/home/h-ghazali/node_modules/fabric-ca-client/lib/FabricCAClient.js:315:13)
at TLSSocket.emit (node:events:381:22)
at TLSSocket.Socket._onTimeout (node:net:481:8)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
Failed to enroll admin user ' + app-admin + : Error: Calling enroll endpoint failed, CONNECTION Timeout
enrollAdmin.js 文件如下
/*
* SPDX-License-Identifier: Apache-2.0
*/
'use strict';
const FabricCAServices = require('fabric-ca-client');
const { FileSystemWallet, X509WalletMixin } = require('fabric-network');
const fs = require('fs');
const path = require('path');
// capture network variables from config.json
const configPath = path.join(process.cwd(), './config.json');
const configJSON = fs.readFileSync(configPath, 'utf8');
const config = JSON.parse(configJSON);
// let connection_file = config.connection_file;
let appAdmin = config.appAdmin;
let appAdminSecret = config.appAdminSecret;
let orgMSPID = config.orgMSPID;
let caName = config.caName;
// const ccpPath = path.join(process.cwd(), './www/blockchain/ibpConnection.json');
// const ccpPath = path.join(process.cwd(), './ibpConnection.json');
// const ccpJSON = fs.readFileSync(ccpPath, 'utf8');
// const ccp = JSON.parse(ccpJSON);
async function main() {
try {
// Create a new CA client for interacting with the CA.
const caURL = caName;
const ca = new FabricCAServices(caURL);
// Create a new file system based wallet for managing identities.
const walletPath = path.join(process.cwd(), 'wallet');
const wallet = new FileSystemWallet(walletPath);
console.log(`Wallet path: ${walletPath}`);
// Check to see if we've already enrolled the admin user.
const adminExists = await wallet.exists(appAdmin);
if (adminExists) {
console.log('An identity for the admin user "admin" already exists in the wallet');
return;
}
// Enroll the admin user, and import the new identity into the wallet.
const enrollment = await ca.enroll({ enrollmentID: appAdmin, enrollmentSecret: appAdminSecret });
const identity = X509WalletMixin.createIdentity(orgMSPID, enrollment.certificate, enrollment.key.toBytes());
wallet.import(appAdmin, identity);
console.log('msg: Successfully enrolled admin user ' + appAdmin + ' and imported it into the wallet');
} catch (error) {
console.error(`Failed to enroll admin user ' + ${appAdmin} + : ${error}`);
process.exit(1);
}
}
main();
解决方案
推荐阅读
- javascript - 如何限制打开多个警报背靠背?
- php - Symfony IDP - openssl 签名错误 EVP_DecryptFinal_ex:错误解密 - SHA256
- javascript - 声明时向组件选择器添加指令 - Angular 7
- javascript - 使用操作按钮在高图表/闪亮中显示/隐藏系列
- java - JWT 自定义过滤器中的身份验证管理器
- php - BitGoSDK neto737\\BitGoSDK\\Enum\\CurrencyCode 未找到
- java - Java:使用 Map 的未知键解析 JSON
- python-3.x - 如何检查所有必需的列或必需列中的任何一个是否可用python
- jquery - jQuery 事件目标/relatedTarget 问题
- django - 我将如何创建一个 gui 来运行 django 项目?