HLF 架构网络无法从节点红色连接到 IBP2 对等体
HLF fabric-network fails to connect to IBP2 peer from node-red
我目前正在使用 IBM Blockchain Platform 2.0。我正在使用 fabric-network 1.4.0
和 fabric-client 1.4.0
.
连接到它
当我在我的机器上从一个简单的 node.js 脚本监听事件时,它运行得非常好。这是示例脚本:
const ccpPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/node-red/fabric-server/config/org1/ibp2/user1/connection.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
const walletPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/IBP2/CHAINCODE/public-resource/profile/wallet');
const wallet = new FileSystemWallet(walletPath);
const gateway = new Gateway();
const options = { wallet, identity: 'user1', discovery: { enabled: true, asLocalhost: false } };
await gateway.connect(ccp, options);
const network = await gateway.getNetwork('CHANNELNAME');
const contract = network.getContract('CCNAME');
const channel = network.getChannel();
const eventHub = channel.newChannelEventHub('IP:PORT');
let event = eventHub.registerChaincodeEvent('CCNAME', 'EVENTREGEX', (event, number, txid, status) => {
console.log(event);
console.log(event.payload.toString());
console.log(number);
}, (error) => {
console.log(error);
}, { startBlock: 0 });
eventHub.connect(true);
但是,我的目标是将此代码包含到节点红色节点中(检查 here。
一些背景信息:目前这些节点不处理可能需要的发现。我工作的目的是将其包含到这些节点中。
因此,我尝试将上面的代码插入到我的节点代码中,结果如下:(相同的代码,它只是一个 copy/paste)
else if (actionType === 'event') {
node.log('EVENT');
const ccPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/node-red/fabric-server/config/org1/ibp2/user1/connection.json');
const ccp = JSON.parse(fs.readFileSync(ccPath, 'utf8'));
const walletPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/IBP2/CHAINCODE/public-resource/profile/wallet');
const wallet = new FileSystemWallet(walletPath);
const gateway = new Gateway();
const options = { wallet, identity: 'user1', discovery: { enabled: true, asLocalHost: false } };
await gateway.connect(ccp, options);
const network = await gateway.getNetwork('CHANEL NAME');
const channel = network.getChannel();
const eventHub = channel.newChannelEventHub('IP:PORT');
let event = eventHub.registerChaincodeEvent('CCNAME', 'REGEX', (event, number, txid, status) => {
console.log(event);
console.log(event.payload.toString());
console.log(number);
}, (error) => {
console.log(error);
}, { startBlock: 0 });
eventHub.connect(true);
// const networkInfo = await connect(identityName, node.connection.discoveryEnabled, node.connection.discoveryAsLocalhost, channelName, contractName, node);
// const channel = networkInfo.network.getChannel();
// await subscribeToEvent(channel, contractName, msg.payload.peerName, msg.payload.startBlock,
// msg.payload.endBlock, msg.payload.timeout, msg.payload.eventName, node, msg);
} else if
它产生以下错误:
{ Error: 14 UNAVAILABLE: Connect Failed
at Object.exports.createStatusError (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\common.js:91:15)
at ClientDuplexStream._emitStatusIfDone (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client.js:233:26)
at ClientDuplexStream._receiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client.js:211:8)
at Object.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:1306:15)
at InterceptingListener._callNext (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:618:8)
at C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:1123:18
code: 14, metadata: Metadata { _internal_repr: {} }, details:
'Connect Failed' }
我检查了两个 "environment" 上的 fabric-network
版本,它是 1.4.0
有人知道有什么不同吗and/or什么会导致这个错误?
编辑:
当通过 npm install PATH
而不是使用 npm link
将包链接到 node-red 时测试包时,出现以下错误:
{ Error: 14 UNAVAILABLE: failed to connect to all addresses
at Object.exports.createStatusError (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\common.js:91:15)
at ClientDuplexStream._emitStatusIfDone (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client.js:233:26)
at ClientDuplexStream._receiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client.js:211:8)
at Object.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:1306:15)
at InterceptingListener._callNext (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:618:8)
at C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:1123:18
code: 14,
metadata: Metadata { _internal_repr: {} },
details: 'failed to connect to all addresses' }
编辑:来自 HLF 日志记录的更多信息。您可以找到完整的日志 here
为了安全起见,除本地主机地址外,所有地址都已更改为 ADDRESS
或 ADDRESS:PORT
(取决于写入的内容)。
使用发现时的当前默认值 (1.4.0-1.4.4) 是将所有返回的 IP 地址转换为本地主机。您需要明确禁用它。在您的代码中,我看到您已经尝试过,但 属性 名称略有错误。它应该是 asLocalhost
和一个小的 h
而你使用了大写的 H
我目前正在使用 IBM Blockchain Platform 2.0。我正在使用 fabric-network 1.4.0
和 fabric-client 1.4.0
.
当我在我的机器上从一个简单的 node.js 脚本监听事件时,它运行得非常好。这是示例脚本:
const ccpPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/node-red/fabric-server/config/org1/ibp2/user1/connection.json');
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
const walletPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/IBP2/CHAINCODE/public-resource/profile/wallet');
const wallet = new FileSystemWallet(walletPath);
const gateway = new Gateway();
const options = { wallet, identity: 'user1', discovery: { enabled: true, asLocalhost: false } };
await gateway.connect(ccp, options);
const network = await gateway.getNetwork('CHANNELNAME');
const contract = network.getContract('CCNAME');
const channel = network.getChannel();
const eventHub = channel.newChannelEventHub('IP:PORT');
let event = eventHub.registerChaincodeEvent('CCNAME', 'EVENTREGEX', (event, number, txid, status) => {
console.log(event);
console.log(event.payload.toString());
console.log(number);
}, (error) => {
console.log(error);
}, { startBlock: 0 });
eventHub.connect(true);
但是,我的目标是将此代码包含到节点红色节点中(检查 here。
一些背景信息:目前这些节点不处理可能需要的发现。我工作的目的是将其包含到这些节点中。
因此,我尝试将上面的代码插入到我的节点代码中,结果如下:(相同的代码,它只是一个 copy/paste)
else if (actionType === 'event') {
node.log('EVENT');
const ccPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/node-red/fabric-server/config/org1/ibp2/user1/connection.json');
const ccp = JSON.parse(fs.readFileSync(ccPath, 'utf8'));
const walletPath = path.resolve('C:/Users/FlorianCastelain/Documents/GitHub/blockchain-code/IBP2/CHAINCODE/public-resource/profile/wallet');
const wallet = new FileSystemWallet(walletPath);
const gateway = new Gateway();
const options = { wallet, identity: 'user1', discovery: { enabled: true, asLocalHost: false } };
await gateway.connect(ccp, options);
const network = await gateway.getNetwork('CHANEL NAME');
const channel = network.getChannel();
const eventHub = channel.newChannelEventHub('IP:PORT');
let event = eventHub.registerChaincodeEvent('CCNAME', 'REGEX', (event, number, txid, status) => {
console.log(event);
console.log(event.payload.toString());
console.log(number);
}, (error) => {
console.log(error);
}, { startBlock: 0 });
eventHub.connect(true);
// const networkInfo = await connect(identityName, node.connection.discoveryEnabled, node.connection.discoveryAsLocalhost, channelName, contractName, node);
// const channel = networkInfo.network.getChannel();
// await subscribeToEvent(channel, contractName, msg.payload.peerName, msg.payload.startBlock,
// msg.payload.endBlock, msg.payload.timeout, msg.payload.eventName, node, msg);
} else if
它产生以下错误:
{ Error: 14 UNAVAILABLE: Connect Failed
at Object.exports.createStatusError (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\common.js:91:15)
at ClientDuplexStream._emitStatusIfDone (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client.js:233:26)
at ClientDuplexStream._receiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client.js:211:8)
at Object.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:1306:15)
at InterceptingListener._callNext (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:618:8)
at C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\grpc\src\client_interceptors.js:1123:18
code: 14, metadata: Metadata { _internal_repr: {} }, details:
'Connect Failed' }
我检查了两个 "environment" 上的 fabric-network
版本,它是 1.4.0
有人知道有什么不同吗and/or什么会导致这个错误?
编辑:
当通过 npm install PATH
而不是使用 npm link
将包链接到 node-red 时测试包时,出现以下错误:
{ Error: 14 UNAVAILABLE: failed to connect to all addresses
at Object.exports.createStatusError (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\common.js:91:15)
at ClientDuplexStream._emitStatusIfDone (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client.js:233:26)
at ClientDuplexStream._receiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client.js:211:8)
at Object.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:1306:15)
at InterceptingListener._callNext (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:618:8)
at C:\Users\FlorianCastelain\Documents\GitHub\node-red-contrib-fabric\node_modules\fabric-network\node_modules\fabric-client\node_modules\grpc\src\client_interceptors.js:1123:18
code: 14,
metadata: Metadata { _internal_repr: {} },
details: 'failed to connect to all addresses' }
编辑:来自 HLF 日志记录的更多信息。您可以找到完整的日志 here
为了安全起见,除本地主机地址外,所有地址都已更改为 ADDRESS
或 ADDRESS:PORT
(取决于写入的内容)。
使用发现时的当前默认值 (1.4.0-1.4.4) 是将所有返回的 IP 地址转换为本地主机。您需要明确禁用它。在您的代码中,我看到您已经尝试过,但 属性 名称略有错误。它应该是 asLocalhost
和一个小的 h
而你使用了大写的 H