Ошибка при использовании клиентского SDK Hyperledger Fabric для версии 1.4 - PullRequest
0 голосов
/ 27 февраля 2019

У меня проблема с использованием клиентского SDK для Hyperledger Fabric версии 1.4.Я получаю следующую ошибку на стороне клиента при вызове JS-кода моего узла.

2019-02-26T23:52:51.165Z - debug: [Channel.js]: getChannelConfig - start for channel mychannel
2019-02-26T23:52:51.165Z - debug: [Client.js]: _getSigningIdentity - admin parameter is boolean :true
2019-02-26T23:52:51.166Z - debug: [TransactionID.js]: constructor - start
2019-02-26T23:52:51.170Z - debug: [TransactionID.js]: const - transaction_id c28fe2ddcb5d825a3a4f3239bb732679c72f5ad1dbb6bada99b5b37653acd85c
2019-02-26T23:52:51.170Z - debug: [Channel.js]: sendTransactionProposal(static) - start
2019-02-26T23:52:51.170Z - debug: [Channel.js]: _buildSignedProposal - start
2019-02-26T23:52:51.170Z - debug: [Channel.js]: _buildSignedProposal - adding function arg:GetConfigBlock
2019-02-26T23:52:51.170Z - debug: [Channel.js]: _buildSignedProposal - adding arg
2019-02-26T23:52:51.170Z - debug: [Channel.js]: _buildSignedProposal - not adding the argument :: argbytes
2019-02-26T23:52:51.171Z - debug: [Channel.js]: _buildSignedProposal - chaincode ID:cscc
2019-02-26T23:52:51.172Z - debug: [Client.js]: getClientCertHash - start
2019-02-26T23:52:51.172Z - debug: [Client.js]: getClientCertHash - no tls client cert
2019-02-26T23:52:51.172Z - debug: [client-utils.js]: buildChannelHeader - type 3 channel_id mychannel tx_id NaN epoch null chaincode_id cscc
2019-02-26T23:52:51.177Z - debug: [client-utils.js]: buildProposal - not adding a transientMap
2019-02-26T23:52:51.192Z - debug: [crypto_ecdsa_aes]: ecdsa signature:  negative=0, words=[3536473, 53194331, 42042421, 23902421, 57221259, 39591199, 8287856, 52148147, 3104552, 2768039, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], length=10, red=null, negative=0, words=[37503158, 30865508, 12495844, 66064117, 55997825, 26418695, 27733325, 26455676, 35150340, 834083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], length=10, red=null, recoveryParam=1
2019-02-26T23:52:51.193Z - debug: [Remote.js]: getUrl::grpc://localhost:7051
2019-02-26T23:52:51.193Z - debug: [Peer.js]: sendProposal - Start ----peer0.org1.example.com grpc://localhost:7051
2019-02-26T23:52:51.196Z - debug: [Remote.js]: Successfully connected to remote gRPC server
2019-02-26T23:52:51.321Z - error: [Peer.js]: sendProposal - timed out after:120
2019-02-26T23:52:51.321Z - error: [Peer.js]: sendProposal - timed out after:120
2019-02-26T23:52:51.322Z - debug: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: REQUEST_TIMEOUT
2019-02-26T23:52:51.322Z - debug: [Channel.js]: getChannelConfig - results received
2019-02-26T23:52:51.322Z - debug: [Channel.js]:  Problem with the initialize :: Error: REQUEST_TIMEOUT

Мой код клиента

/*
SPDX-License-Identifier: Apache-2.0
*/

/*
 * This application has 6 basic steps:
 * 1. Select an identity from a wallet
 * 2. Connect to network gateway
 * 3. Access PO network
 * 4. Construct request to issue commercial PO
 * 5. Submit transaction
 * 6. Process response
 */

'use strict';

// Bring key classes into scope, most importantly Fabric SDK network class
const fs = require('fs');
const yaml = require('js-yaml');
const { FileSystemWallet, Gateway } = require('fabric-network');
const CommercialPO = require('../contract/lib/PO.js');

// A wallet stores a collection of identities for use
//const wallet = new FileSystemWallet('../user/isabella/wallet');
const wallet = new FileSystemWallet('../identity/user/isabella/wallet');

// Main program function
async function main() {

  // A gateway defines the peers used to access Fabric networks
  const gateway = new Gateway();

  // Main try/catch block
  try {

    // Specify userName for network access
    // const userName = 'isabella.issuer@magnetocorp.com';
    const userName = 'User1@org1.example.com';

    // Load connection profile; will be used to locate a gateway
    let connectionProfile = yaml.safeLoad(fs.readFileSync('/Users/jugmabora/work/Hyperledger-Fabric/fabric-samples/usecase1/organization/walmart/gateway/first-network-sdk-config.yaml', 'utf8'));

    // Set connection options; identity and wallet
    let connectionOptions = {
      identity: userName,
      wallet: wallet,
      discovery: { enabled:false, asLocalhost:true }
    };

    // Connect to gateway using application specified parameters
    console.log('Connect to Fabric gateway.');

    await gateway.connect(connectionProfile, connectionOptions);

    // Access PONet network
    console.log('Use network channel: mychannel.');

    const network = await gateway.getNetwork('mychannel');

    // Get addressability to commercial PO contract
    console.log('Use org.blumeglobal.commercialPO smart contract.');

    const contract = await network.getContract('pocontract', 'org.blumeglobal.commercialPO');

    // issue PO
    console.log('Submit commercial PO issue transaction.');

    const issueResponse = await contract.submitTransaction('issue', 'Walmart', '00001', 'Walmart', '2020-05-31', '2020-11-30', '2020-12-01', 'SKU007', '10');

    // process response
    console.log('Process issue transaction response.');

    let po = CommercialPO.fromBuffer(issueResponse);

    console.log(JSON.stringify(po));

    console.log(`${po.issuer} issued commercial PO : ${po.poNumber} for quantity ${po.quantity}`);
    console.log('Transaction complete.');

  } catch (error) {

    console.log(`Error processing transaction. ${error}`);
    console.log(error.stack);

  } finally {

    // Disconnect from the gateway
    console.log('Disconnect from Fabric gateway.')
    gateway.disconnect();

  }
}
main().then(() => {

  console.log('Issue program complete.');

}).catch((e) => {

  console.log('Issue program exception.');
  console.log(e);
  console.log(e.stack);
  process.exit(-1);

});

Мой first-network-sdk-config.yaml

#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# The network connection profile provides client applications the information about the target
# blockchain network that are necessary for the applications to interact with it. These are all
# knowledge that must be acquired from out-of-band sources. This file provides such a source.
#
#
# Schema version of the content. Used by the SDK to apply the corresponding parsing rules.
#
name: "byfn"
x-type: "hlfv1"
description: "The basic network"
version: "1.0" 

client:
  organization: Org1
  connection:
    timeout:
      peer:
        endorser: 300
        eventHub: 300
        eventReg: 300
      orderer: 300
#
# [Optional]. But most apps would have this section so that channel objects can be constructed
# based on the content below. If an app is creating channels, then it likely will not need this
# section.
#
#
# list of participating organizations in this network
#
channels:
  mychannel:
    orderers: orderer.example.com
    peers:
      peer0.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        eventSource: true
      peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        eventSource: true
      peer0.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        eventSource: true
      peer1.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        eventSource: true

organizations:
  Org1:
    mspid: Org1MSP
    peers:
      - peer0.org1.example.com
      - peer1.org1.example.com
    certificateAuthorities:
      - ca.org1.example.com
    x-adminCert:
      path: /Users/jugmabora/work/Hyperledger-Fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/admincerts/Admin@org1.example.com-cert.pem
    x-adminKeyStore:
      path: /Users/jugmabora/work/Hyperledger-Fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore 

  # the profile will contain public information about organizations other than the one it belongs to.
  # These are necessary information to make transaction lifecycles work, including MSP IDs and
  # peers with a public URL to send transaction proposals. The file will not contain private
  # information reserved for members of the organization, such as admin key and certificate,
  # fabric-ca registrar enroll ID and secret, etc.
  Org2:
    mspid: Org2MSP
    peers:
      - peer0.org2.example.com
      - peer1.org2.example.com
    certificateAuthorities:
      - ca.org2.example.com
    x-adminCert:
      path: /Users/jugmabora/work/Hyperledger-Fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/admincerts/Admin@org2.example.com-cert.pem
    x-adminKeyStore:
      path: /Users/jugmabora/work/Hyperledger-Fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore

  # Orderer Org name
  ordererorg:
      # Membership Service Provider ID for this organization
      mspID: OrdererMSP
#
# List of orderers to send transaction and channel create/update requests to. For the time
# being only one orderer is needed. If more than one is defined, which one get used by the
# SDK is implementation specific. Consult each SDK's documentation for its handling of orderers.
#
orderers:
  orderer.example.com:
    url: grpc://localhost:7050

    # these are standard properties defined by the gRPC library
    # they will be passed in as-is to gRPC client constructor
    grpcOptions:
      ssl-target-name-override: orderer.example.com
      request-timeout: 120

#
# List of peers to send various requests to, including endorsement, query
# and event listener registration.
#
peers:
  peer0.org1.example.com:
    # this URL is used to send endorsement and query requests
    url: grpc://localhost:7051
    grpcOptions:
      ssl-target-name-override: peer0.org1.example.com
      request-timeout: 120

  peer1.org1.example.com:
    # this URL is used to send endorsement and query requests
    url: grpc://localhost:8051
    grpcOptions:
      ssl-target-name-override: peer1.org1.example.com
      request-timeout: 120

  peer0.org2.example.com:
    url: grpc://localhost:9051
    grpcOptions:
      ssl-target-name-override: peer0.org2.example.com
      request-timeout: 120

  peer1.org2.example.com:
    url: grpc://localhost:10051
    grpcOptions:
      ssl-target-name-override: peer1.org2.example.com
      request-timeout: 120

certificateAuthorities:
  ca.org1.example.com:
    url: http://localhost:7054
    registrar:
      - enrollId: admin
        enrollSecret: adminpw
    caName: ca-org1
    httpOptions:
      verify: false

  ca.org2.example.com:
    url: http://localhost:8054
    registrar:
      - enrollId: admin
        enrollSecret: adminpw
    caName: ca-org2
    httpOptions:
      verify: false
...