Problem
I was following this Hyperledger Fabric tutorial: Building Your First Network
There’s a shell script called byfn.sh which stands for Build Your First Network.
I ran the following command which generates the required certificates and genesis block:
./byfn.sh generate
And then, ran this command which brings up the network with docker-compose up
:
./byfn.sh up
While running the above command ./byfn.sh up
, I got the following error:
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
!!!!!!!!!!!!!!! After 5 attempts, peer0.org1 has failed to join channel ‘mychannel’ !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========ERROR !!!! Test failed
Solution
Found different solutions over the internet.
1) Clear docker containers, images, and volumes
docker rm -f $(docker ps -aq) && docker rmi -f $(docker images | grep dev | awk '{print $3}') && docker volume prune
2) Clear the network (bring the network down) and re-run the up
command
./byfn.sh down
./byfn.sh generate
./byfn.sh up
3) Re-install the platform-specific binaries and config files
Visit this tutorial: Install Samples, Binaries and Docker Images
As mentioned there:
- Open terminal
- Go to your
fabric-samples
directory - Run the following command:
curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0
This command will:
- Install the Hyperledger Fabric platform-specific binaries and config files for the version specified into the root of the fabric-samples repository
-
Download the Hyperledger Fabric docker images for the version specified
4) Update docker
and docker-compose
to the latest version
This solution finally solved the error in my case.
In the Prerequisites page, it says that we need:
Docker version 17.06.2-ce or greater
Docker Compose version 1.14.0 or greater
I had:
docker version 18.x.x
docker-compose version 1.21.1
But, they were not the latest version.
Hence, I just gave a try to update the docker and docker-compose to the latest version.
And, then ran the byfn.sh
shell script and everything went fine without any error.
./byfn.sh down
./byfn.sh generate
./byfn.sh up
Hope this helps. Thanks.