0

(1) Hi I installed the default Hyperledger Fabric network (./byfn.sh up) (2) Then I installed Composer CLI (3) Created PeerAdmin@hlfv1 card (Check code below: createPeerAdminCard.sh) (4) I installed a .BNA file with 'composer network install' command (5) Then I tried to start the Business network (ie composer network start) and I received the following error:

Starting business network definition. This may take a minute... Error: Error trying to start business network. Error: Unable to initalize channel. Attempted to contact 4 Peers.Last error was Error: Error: REQUEST_TIMEOUT Command failed

My Goal is to interact with the default Fabric network using Composer and load BNA.

createPeerAdminCard.sh

#!/bin/bash

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
# http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Usage() {
    echo ""
    echo "Usage: ./createPeerAdminCard.sh [-h host] [-n]"
    echo ""
    echo "Options:"
    echo -e "\t-h or --host:\t\t(Optional) name of the host to specify in the connection profile"
    echo -e "\t-n or --noimport:\t(Optional) don't import into card store"
    echo ""
    echo "Example: ./createPeerAdminCard.sh"
    echo ""
    exit 1
}

Parse_Arguments() {
    while [ $# -gt 0 ]; do
        case $1 in
            --help)
                HELPINFO=true
                ;;
            --host | -h)
                shift
                HOST="$1"
                ;;
            --noimport | -n)
                NOIMPORT=true
                ;;
        esac
        shift
    done
}

HOST=localhost
Parse_Arguments $@

if [ "${HELPINFO}" == "true" ]; then
    Usage
fi

# Grab the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ -z "${HL_COMPOSER_CLI}" ]; then
  HL_COMPOSER_CLI=$(which composer)
fi

echo
# check that the composer command exists at a version >v0.16
COMPOSER_VERSION=$("${HL_COMPOSER_CLI}" --version 2>/dev/null)
COMPOSER_RC=$?

if [ $COMPOSER_RC -eq 0 ]; then
    AWKRET=$(echo $COMPOSER_VERSION | awk -F. '{if ($2<19) print "1"; else print "0";}')
    if [ $AWKRET -eq 1 ]; then
        echo Cannot use $COMPOSER_VERSION version of composer with fabric 1.1, v0.19 or higher is required
        exit 1
    else
        echo Using composer-cli at $COMPOSER_VERSION
    fi
else
    echo 'No version of composer-cli has been detected, you need to install composer-cli at v0.19 or higher'
    exit 1
fi

cat << EOF > DevServer_connection.json
{
    "name": "hlfv1",
    "x-type": "hlfv1",
    "x-commitTimeout": 300,
    "version": "1.0.0",
    "client": {
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300",
                    "eventHub": "300",
                    "eventReg": "300"
                },
                "orderer": "300"
            }
        }
    },
    "channels": {
        "mychannel": {
            "orderers": [
                "orderer.example.com"
            ],
            "peers": {
                "peer0.org1.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                },
                "peer1.org1.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                },
                "peer0.org2.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                },
                "peer1.org2.example.com": {
                    "endorsingPeer": true,
                    "chaincodeQuery": true,
                    "ledgerQuery": true,
                    "eventSource": true
                }
            }

        }
    },
    "organizations": {
        "Org1": {
            "mspid": "Org1MSP",
            "peers": [
                "peer0.org1.example.com",
                "peer1.org1.example.com"
            ],
            "certificateAuthorities": [
                "ca.org1.example.com"
            ]
        },
        "Org2": {
            "mspid": "Org2MSP",
            "peers": [
                "peer0.org2.example.com",
                "peer1.org2.example.com"
            ],
            "certificateAuthorities": [
                "ca.org2.example.com"
            ]
        }
    },
    "orderers": {
        "orderer.example.com": {
            "url": "grpc://orderer.example.com:7050"
        }
    },
    "peers": {
        "peer0.org1.example.com": {
            "url": "grpc://peer0.org1.example.com:7051",
            "eventUrl": "grpc://peer0.org1.example.com:7053"
        },
        "peer1.org1.example.com": {
            "url": "grpc://peer1.org1.example.com:7051",
            "eventUrl": "grpc://peer0.org1.example.com:7053"
        },
        "peer0.org2.example.com": {
            "url": "grpc://peer0.org2.example.com:7051",
            "eventUrl": "grpc://peer0.org2.example.com:7053"
        },
        "peer1.org2.example.com": {
            "url": "grpc://peer1.org2.example.com:7051",
            "eventUrl": "grpc://peer1.org2.example.com:7053"
        }
    },
    "certificateAuthorities": {
        "ca.org1.example.com": {
            "url": "http://ca.org1.example.com:7054",
            "caName": "ca.org1.example.com"
        },
        "ca.org2.example.com": {
            "url": "http://ca.org2.example.com:7054",
            "caName": "ca.org2.example.com"
        }
    }
}
EOF

PRIVATE_KEY="${DIR}"/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/fd5a91d23b5607ee968bac994858850d25b6b2903b2c62a3a5532baad4203c9d_sk
CERT="${DIR}"/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem

if [ "${NOIMPORT}" != "true" ]; then
    CARDOUTPUT=/tmp/PeerAdmin@hlfv1.card
else
    CARDOUTPUT=PeerAdmin@hlfv1.card
fi

"${HL_COMPOSER_CLI}"  card create -p DevServer_connection.json -u PeerAdmin -c "${CERT}" -k "${PRIVATE_KEY}" -r PeerAdmin -r ChannelAdmin --file $CARDOUTPUT

if [ "${NOIMPORT}" != "true" ]; then
    if "${HL_COMPOSER_CLI}"  card list -c PeerAdmin@hlfv1 > /dev/null; then
        "${HL_COMPOSER_CLI}"  card delete -c PeerAdmin@hlfv1
    fi

    "${HL_COMPOSER_CLI}"  card import --file /tmp/PeerAdmin@hlfv1.card 
    "${HL_COMPOSER_CLI}"  card list
    echo "Hyperledger Composer PeerAdmin card has been imported, host of fabric specified as '${HOST}'"
    rm /tmp/PeerAdmin@hlfv1.card
else
    echo "Hyperledger Composer PeerAdmin card has been created, host of fabric specified as '${HOST}'"
fi

2 Answers2

0

Make sure you install the development environment and prerequisites correctly, also the composer version and fabric version should be uptodate. Then Follow this tutorial step by step for deploying your business network in a multi-peer multi-organization fabric network and you should be fine.

https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-multi-org

0

A REQUEST_TIMEOUT can occur with the failure to build the Chaincode containers for all peers within the default timeout period of 5 mins through lack of system resources or poor network connections.This can be a problem for the Multi-Org tutorial, and possibly for single peer installs. As part of the Composer Network Start, Fabric tries to build a new chaincode Container which includes npm install commands. A more fundamental error suggests that your Fabric is not configured correctly, or even that the peers have joined the channel you defined your connection profile.

See answer part 2 here Error in starting hyperledger fabric network with hyperledger composer and would also suggest to read the info in the Composer Wiki (scroll down to / search for 'REQUEST_TIMEOUT') for more info and tips on troubleshooting.

Paul O'Mahony
  • 6,740
  • 1
  • 10
  • 15