Blockchain Hyperledger Fabric — Errors & Solutions

source: twenty20.com

Hello, In this article I wanted to share some of the errors you might face & the possible solutions.

please note that, I have faced “n” number of errors while I was working in Blockchain project, I have spent countless hours reading out articles, reaching out experts to fix the same. This article is to just help the people who are beginners & struggling to solve the errors that are quite often pop up during your development stage. If you have any errors that are not listed here, please feel free to comments, will get it added .

Error No 1:

Error: Error trying to ping. Error: 2 UNKNOWN: make sure the chaincode test-registry has been successfully instantiated and try again: could not find chaincode with name ‘test-registry’

Solutions: Make sure that you have installed the network before you start. Use below commands to start the network

- composer network install — card PeerAdmin@hlfv1 — archiveFile network-name@0.0.1.bna
- composer network start — networkName networkname — networkVersion 0.0.1 — networkAdmin admin — networkAdminEnrollSecret adminpw — card PeerAdmin@hlfv1 — file networkadmin.card

Error No 2:

Error:
docker: Error response from daemon: Conflict. The container name “/composer-playground” is already in use by container “9f224b04663a4fa65f50843e5f7e28f7e7df662507a9b42ae5dfc72fd3433405”. You have to remove (or rename) that container to be able to reuse that name.
See ‘docker run — help’.

Solutions: Kill the dockers by running following command & re-execute the composer-playground command (“docker run — name composer-playground — publish 8080:8080 hyperledger/composer-playground”)

docker rm -f $(docker ps -a -q)
docker kill $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi $(docker images dq-* -q)

Error No 3:

Error: Chaincode already exists error

Solutions: Kill docker images, stop fabric & start fabric again. Once it runs fine, then start deploying the business network card again.

./stopFabric.sh
./startFabric.sh

Error No 4:

Error: NG Serve Error

Solutions: Use npm instead of ng serve.

npm start

Error No 5:

Error: Authorisation error REST-API

Solutions: Setup COMPOSER_PROVIDERS in environment variable, and restart the composer-rest-server

Follow this link https://github.com/hyperledger/composer/blob/master/packages/composer-website/jekylldocs/integrating/enabling-rest-authentication.md

Error No 6:

Discovering types from business network definition …
Connection fails: Error: Error trying to ping. Error: 2 UNKNOWN: make sure the chaincode ‘network-name’ has been successfully instantiated and try again: could not find chaincode with name ‘network-name’

Solutions: Make sure to install & start the business network before you run composer-rest-server command.

1)composer network install — card PeerAdmin@hlfv1 — archiveFile network-name@0.0.1.bna
2)composer network start — networkName ‘network-name’ — networkVersion 0.0.1 — networkAdmin admin — networkAdminEnrollSecret adminpw — card PeerAdmin@hlfv1 — file networkadmin.card

ERROR No 7:

ERROR: for couchdb Cannot create container for service couchdb: Conflict. The container name “/couchdb” is already in use by container “de8ceaf8f21b53bb4c9883eb618448f6f07c7690bea8ab122ef3b689e846eab4”. You have to remove (or rename) that Creating orderer.example.com … error

Solutions: Kill the dockers by running following command

docker rm -f $(docker ps -aq)

Error No : 8

Error: Cannot find module ‘fabric-client’

Solution: Perform npm update, this will install necessary plug-in’s & modules.

npm update

Error No : 9

Error: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install?

Solution: perform npm install, this will install necessary node_modules.

npm install

Error No: 10

Error: Angular2 app generated by “yo fabric-composer” does not have UI for Transactions

Solutions: We have issue open in Github — please follow the issue for more updates

Solution Update :

Go to <transaction>.component.html file in src/app/<transaction> folder and check for line
<button type=”button” class=”btn btn-primary invokeTransactionBtn” data-toggle=”modal”>Invoke</button>

Just add data-target attribute to it as below:
<button type=”button” class=”btn btn-primary invokeTransactionBtn” data-toggle=”modal” data-target=”#addTransactionModal”>Invoke</button>

#addTransactionModal is the id for the modal which has the form.

LInk : https://github.com/hyperledger/composer/issues/4121

Error No: 11

Error: Connection fails: Error: Error trying to ping. Error: Composer runtime (0.19.8) is not compatible with client (0.19.5)
It will be retried for the next request.

Solutions:

./stopFabric.sh
npm install -g composer-playground@0.19.8
composer-rest-server

Error No 12:

ERROR: curl: (7) Failed to connect to localhost port 49160: Connection refused

Solution: docker run — rm -i -t -p 49160:8080 <your username>/node-app

Note: This kind of error will only shoot up, when you build your own docker container & trying to execute it.

Error No 13:

ERROR: network composer_default id b1067bdec4ca1800510fc9cc1f5d3500736e48920693b03831df0d8d8472ffac has active endpoints

You might hit this error, when you trying to execute new fabric-server(but the old one still in running state)

Solutions : Stop the already running fabric server, using .stopFabric.sh or .stop.sh(whatever the script you has in your network), then apply the following command to remove the running docker containers, and re-execute the fabric

docker rm -f $(docker ps -a -q)

Error No 14:

Error: Node.JS Error: ENOSPC

Solution : https://stackoverflow.com/questions/22475849/node-js-error-enospc .

Error NO 15:

Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded

Solution : You need to review the Orderer logs first to ensure what’s happening under the hood.

Step 1: docker logs orderer.example.com

Step 2: go to configtx.yaml file and check the capabilities

ensure you have right versions downloaded

Error No 16:

Error: Failed to import the business network card
Failed to import the business network card
keyword: required
dataPath: .peers[‘peer0.org1.example.com’]
schemaPath: #/required
params: 
 missingProperty: eventUrl
message: should have required property ‘eventUrl’
Error: Errors found in the connection profile in the card
Command failed

Solution: You are trying to run fabric v1.1, but it pulls out fabric v1.2 createpeeradmin.sh

Error No : 17

Error: container is marked for removal and cannot be started

Sometimes, when you kill / remove containers, it would sit up in “Removal Queue” or in “Dead Status”, that would be mounted forever and will not allow you to run your next steps.. So you have to remove the containers using below command. this kills all the containers that are marked in DEAD state.

Solution: docker rm $(docker ps — all -q -f status=dead)

Error No : 18

Error: sendPeersProposal — Promise is rejected: Error: chaincode with name ‘chain-code-name’ already exists

Situtation — Occurred while instantiating chaincode

Solutions: This error mostly would occur due to the fact that, chaincode would have already instantiated on peers. So get rid of this, remove the node_modules & do npm install once it finishes fine, restart the “install chaincode” and then “instantitaet chaincode”.

Or

Use different chain_node id

Error No : 19

CRIT 008 Error on outputBlock: Error writing genesis block: open ./channel-artifacts/genesis.block: no such file or directory

Solution : Create channel-artifacts folder before you run the command

./configtxgen -profile FourOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

Error No : 20

Error: readBlock -> DEBU 00a Got status: &{FORBIDDEN} Error: can’t read the block: &{FORBIDDEN}

Solution : Make sure, before you start your network no other containers are running behind. This error occurs due to permission issues, that containers are in conflict with existing containers. Goahead, kill the containers using docker rm -f $(docker ps -a -q) command & restart your network.

Error No : 21

grpc: addrConn.createTransport failed to connect to {peer0.org1.example.com:7051 0 <nil>}. Err :connection error: desc = “transport: Error while dialing dial tcp: lookup peer0.org1.example.com on 127.0.0.11:53: no such host”. Reconnecting…

Solution: .. to be identified…

Error No : 22

Error: Network Not found issue

Solution : Go to ./peer-base.yaml and change CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE to the corresponding network name. Clean the docker containers and then rebuild

Error No : 23

Error: Sending the Instantiate Proposal ..
error: [Peer.js]: sendProposal — timed out after:45000

Solution: …

Note: After some time, it ran fine. but I will keep it updated when I face it again.

Error No : 24

Error: could not assemble transaction: ProposalResponsePayloads do not match — proposal response: version:1 response:<status:200 >

Solution: Make sure, yo have installed Chaincode in the peers you are trying to invoke the transactions. Set the environment variables for the peers. For instance :

CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID=”Org2MSP” CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -

I would love to keep adding all the errors and possible solutions in single article, so that it can help anyone in future. Please do review & also add your learnings in comment section. I will get it added here. Let’s create a cheatsheet!

Thank you for taking out few mins to read..in my next article, I would like to give very short way to setup business network & play with angular applications. if you like this article, please like, clap which will motivate me to write more for community.