title: Error in running byfn: failed to endorse chaincode install, rpc error code unavailable
body: <p>I am on CentOS 7, installed all prerequisites, cloned the fabric-samples git repository.</p>
  
  <p>I am referring to the tutorial "Building Your First Network", found <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html#bring-up-the-network" rel="nofollow noreferrer">here</a>. At this point I have successfully run the command</p>
  
  <pre><code>./byfn.sh generate
  </code></pre>
  
  <p>Now I want to execute the Java chaincode, so I run</p>
  
  <pre><code>./byfn.sh up -l java
  </code></pre>
  
  <p>Right after the START sign, I see the following output:</p>
  
  <pre><code>Build your first network (BYFN) end-to-end test
  
  + peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
  Channel name : mychannel
  Creating channel...
  + res=0
  + set +x
  2020-02-21 09:14:36.439 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:36.463 UTC [cli.common] readBlock -&gt; INFO 002 Expect block, but got status: &amp;{NOT_FOUND}
  2020-02-21 09:14:36.466 UTC [channelCmd] InitCmdFactory -&gt; INFO 003 Endorser and orderer connections initialized
  2020-02-21 09:14:36.667 UTC [cli.common] readBlock -&gt; INFO 004 Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:36.670 UTC [channelCmd] InitCmdFactory -&gt; INFO 005 Endorser and orderer connections initialized
  2020-02-21 09:14:36.871 UTC [cli.common] readBlock -&gt; INFO 006 Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:36.876 UTC [channelCmd] InitCmdFactory -&gt; INFO 007 Endorser and orderer connections initialized
  2020-02-21 09:14:37.077 UTC [cli.common] readBlock -&gt; INFO 008 Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:37.081 UTC [channelCmd] InitCmdFactory -&gt; INFO 009 Endorser and orderer connections initialized
  2020-02-21 09:14:37.281 UTC [cli.common] readBlock -&gt; INFO 00a Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:37.284 UTC [channelCmd] InitCmdFactory -&gt; INFO 00b Endorser and orderer connections initialized
  2020-02-21 09:14:37.486 UTC [cli.common] readBlock -&gt; INFO 00c Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:37.489 UTC [channelCmd] InitCmdFactory -&gt; INFO 00d Endorser and orderer connections initialized
  2020-02-21 09:14:37.692 UTC [cli.common] readBlock -&gt; INFO 00e Received block: 0
  ===================== Channel 'mychannel' created =====================
  </code></pre>
  
  <p>But the test still continues with no issues until the chaincode installation part.</p>
  
  <pre><code>===================== Chaincode is packaged on peer0.org1 =====================
  
  Installing chaincode on peer0.org1...
  + peer lifecycle chaincode install mycc.tar.gz
  + res=1
  + set +x
  Error: failed to endorse chaincode install: rpc error: code = Unavailable desc = transport is closing
  !!!!!!!!!!!!!!! Chaincode installation on peer0.org1 has failed !!!!!!!!!!!!!!!!
  ========= ERROR !!! FAILED to execute End-2-End Scenario ===========
  </code></pre>
  
  <p>The test stalls for quite some time at the <code>Installing chaincode on peer0.org1...</code> line, before ending in this error message.</p>
  
  <hr>
  
  <p>The following is the full output:</p>
  
  <pre><code>Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
  Continue? [Y/n] Y
  proceeding ...
  LOCAL_VERSION=2.0.0
  DOCKER_IMAGE_VERSION=2.0.0
  /root/hyperledger/fabric/bin/cryptogen
  
  ##########################################################
  ##### Generate certificates using cryptogen tool #########
  ##########################################################
  + cryptogen generate --config=./crypto-config.yaml
  org1.example.com
  org2.example.com
  + res=0
  + set +x
  
  Generate CCP files for Org1 and Org2
  /root/hyperledger/fabric/bin/configtxgen
  ##########################################################
  #########  Generating Orderer Genesis block ##############
  ##########################################################
  2020-02-21 17:14:15.274 +08 [common.tools.configtxgen] main -&gt; INFO 001 Loading configuration
  2020-02-21 17:14:15.309 +08 [common.tools.configtxgen.localconfig] completeInitialization -&gt; INFO 002 orderer type: etcdraft
  2020-02-21 17:14:15.310 +08 [common.tools.configtxgen.localconfig] completeInitialization -&gt; INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
  2020-02-21 17:14:15.310 +08 [common.tools.configtxgen.localconfig] Load -&gt; INFO 004 Loaded configuration: /root/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
  2020-02-21 17:14:15.312 +08 [common.tools.configtxgen] doOutputBlock -&gt; INFO 005 Generating genesis block
  2020-02-21 17:14:15.312 +08 [common.tools.configtxgen] doOutputBlock -&gt; INFO 006 Writing genesis block
  
  #################################################################
  ### Generating channel configuration transaction 'channel.tx' ###
  #################################################################
  + configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
  2020-02-21 17:14:15.347 +08 [common.tools.configtxgen] main -&gt; INFO 001 Loading configuration
  2020-02-21 17:14:15.390 +08 [common.tools.configtxgen.localconfig] Load -&gt; INFO 002 Loaded configuration: /root/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
  2020-02-21 17:14:15.391 +08 [common.tools.configtxgen] doOutputChannelCreateTx -&gt; INFO 003 Generating new channel configtx
  2020-02-21 17:14:15.393 +08 [common.tools.configtxgen] doOutputChannelCreateTx -&gt; INFO 004 Writing new channel tx
  + res=0
  + set +x
  
  #################################################################
  #######    Generating anchor peer update for Org1MSP   ##########
  #################################################################
  + configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
  2020-02-21 17:14:15.434 +08 [common.tools.configtxgen] main -&gt; INFO 001 Loading configuration
  2020-02-21 17:14:15.477 +08 [common.tools.configtxgen.localconfig] Load -&gt; INFO 002 Loaded configuration: /root/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
  2020-02-21 17:14:15.477 +08 [common.tools.configtxgen] doOutputAnchorPeersUpdate -&gt; INFO 003 Generating anchor peer update
  2020-02-21 17:14:15.479 +08 [common.tools.configtxgen] doOutputAnchorPeersUpdate -&gt; INFO 004 Writing anchor peer update
  + res=0
  + set +x
  
  #################################################################
  #######    Generating anchor peer update for Org2MSP   ##########
  #################################################################
  + configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
  2020-02-21 17:14:15.525 +08 [common.tools.configtxgen] main -&gt; INFO 001 Loading configuration
  2020-02-21 17:14:15.576 +08 [common.tools.configtxgen.localconfig] Load -&gt; INFO 002 Loaded configuration: /root/hyperledger/fabric/fabric-samples/first-network/configtx.yaml
  2020-02-21 17:14:15.576 +08 [common.tools.configtxgen] doOutputAnchorPeersUpdate -&gt; INFO 003 Generating anchor peer update
  2020-02-21 17:14:15.578 +08 [common.tools.configtxgen] doOutputAnchorPeersUpdate -&gt; INFO 004 Writing anchor peer update
  + res=0
  + set +x
  
  Creating network "net_byfn" with the default driver
  Creating volume "net_orderer.example.com" with default driver
  Creating volume "net_peer0.org1.example.com" with default driver
  Creating volume "net_peer1.org1.example.com" with default driver
  Creating volume "net_peer0.org2.example.com" with default driver
  Creating volume "net_peer1.org2.example.com" with default driver
  Creating volume "net_orderer2.example.com" with default driver
  Creating volume "net_orderer3.example.com" with default driver
  Creating volume "net_orderer4.example.com" with default driver
  Creating orderer.example.com ... done
  Creating cli ... done
  Creating orderer4.example.com ...
  Creating peer1.org2.example.com ...
  Creating orderer3.example.com ...
  Creating orderer5.example.com ...
  Creating peer0.org2.example.com ...
  Creating peer0.org1.example.com ...
  Creating orderer.example.com ...
  Creating orderer2.example.com ...
  Creating cli ...
  CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS                      PORTS                                NAMES
  a25f3414f14e        hyperledger/fabric-tools:latest     "/bin/bash"              1 second ago        Up Less than a second                                            cli
  85e4e7490b95        hyperledger/fabric-orderer:latest   "orderer"                4 seconds ago       Up Less than a second       7050/tcp, 0.0.0.0:8050-&gt;8050/tcp     orderer2.example.com
  6f393ad561dc        hyperledger/fabric-peer:latest      "peer node start"        4 seconds ago       Up Less than a second       0.0.0.0:7051-&gt;7051/tcp               peer0.org1.example.com
  6cfd44256f6d        hyperledger/fabric-orderer:latest   "orderer"                4 seconds ago       Up Less than a second       0.0.0.0:7050-&gt;7050/tcp               orderer.example.com
  691f224ac19a        hyperledger/fabric-orderer:latest   "orderer"                5 seconds ago       Up 1 second                 7050/tcp, 0.0.0.0:11050-&gt;11050/tcp   orderer5.example.com
  930177cb2965        hyperledger/fabric-peer:latest      "peer node start"        5 seconds ago       Up 1 second                 7051/tcp, 0.0.0.0:9051-&gt;9051/tcp     peer0.org2.example.com
  cc4fc902a8f0        hyperledger/fabric-peer:latest      "peer node start"        5 seconds ago       Up 1 second                 7051/tcp, 0.0.0.0:10051-&gt;10051/tcp   peer1.org2.example.com
  b192db94069c        hyperledger/fabric-orderer:latest   "orderer"                5 seconds ago       Up 1 second                 7050/tcp, 0.0.0.0:10050-&gt;10050/tcp   orderer4.example.com
  6db78ac784c8        hyperledger/fabric-orderer:latest   "orderer"                5 seconds ago       Up 2 seconds                7050/tcp, 0.0.0.0:9050-&gt;9050/tcp     orderer3.example.com
  1bea7b96c621        hyperledger/fabric-peer:latest      "peer node start"        5 seconds ago       Up 1 second                 7051/tcp, 0.0.0.0:8051-&gt;8051/tcp     peer1.org1.example.com
  d23e83c3cde5        hyperledger/fabric-javaenv:2.0      "/bin/sh -c ./build.…"   17 minutes ago      Exited (0) 15 minutes ago                                        goofy_goldstine
  Sleeping 15s to allow Raft cluster to complete booting
  Vendoring Go dependencies ...
  ~/hyperledger/fabric/fabric-samples/chaincode/abstore/go ~/hyperledger/fabric/fabric-samples/first-network
  ./byfn.sh: line 180: go: command not found
  ~/hyperledger/fabric/fabric-samples/first-network
  Finished vendoring Go dependencies
  
   ____    _____      _      ____    _____
  / ___|  |_   _|    / \    |  _ \  |_   _|
  \___ \    | |     / _ \   | |_) |   | |
   ___) |   | |    / ___ \  |  _ &lt;    | |
  |____/    |_|   /_/   \_\ |_| \_\   |_|
  
  Build your first network (BYFN) end-to-end test
  
  + peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
  Channel name : mychannel
  Creating channel...
  + res=0
  + set +x
  2020-02-21 09:14:36.439 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:36.463 UTC [cli.common] readBlock -&gt; INFO 002 Expect block, but got status: &amp;{NOT_FOUND}
  2020-02-21 09:14:36.466 UTC [channelCmd] InitCmdFactory -&gt; INFO 003 Endorser and orderer connections initialized
  2020-02-21 09:14:36.667 UTC [cli.common] readBlock -&gt; INFO 004 Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:36.670 UTC [channelCmd] InitCmdFactory -&gt; INFO 005 Endorser and orderer connections initialized
  2020-02-21 09:14:36.871 UTC [cli.common] readBlock -&gt; INFO 006 Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:36.876 UTC [channelCmd] InitCmdFactory -&gt; INFO 007 Endorser and orderer connections initialized
  2020-02-21 09:14:37.077 UTC [cli.common] readBlock -&gt; INFO 008 Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:37.081 UTC [channelCmd] InitCmdFactory -&gt; INFO 009 Endorser and orderer connections initialized
  2020-02-21 09:14:37.281 UTC [cli.common] readBlock -&gt; INFO 00a Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:37.284 UTC [channelCmd] InitCmdFactory -&gt; INFO 00b Endorser and orderer connections initialized
  2020-02-21 09:14:37.486 UTC [cli.common] readBlock -&gt; INFO 00c Expect block, but got status: &amp;{SERVICE_UNAVAILABLE}
  2020-02-21 09:14:37.489 UTC [channelCmd] InitCmdFactory -&gt; INFO 00d Endorser and orderer connections initialized
  2020-02-21 09:14:37.692 UTC [cli.common] readBlock -&gt; INFO 00e Received block: 0
  ===================== Channel 'mychannel' created =====================
  
  Having all peers join the channel...
  + peer channel join -b mychannel.block
  + res=0
  + set +x
  2020-02-21 09:14:37.763 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:37.783 UTC [channelCmd] executeJoin -&gt; INFO 002 Successfully submitted proposal to join channel
  ===================== peer0.org1 joined channel 'mychannel' =====================
  
  + peer channel join -b mychannel.block
  + res=0
  + set +x
  2020-02-21 09:14:40.850 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:40.869 UTC [channelCmd] executeJoin -&gt; INFO 002 Successfully submitted proposal to join channel
  ===================== peer1.org1 joined channel 'mychannel' =====================
  
  + peer channel join -b mychannel.block
  + res=0
  + set +x
  2020-02-21 09:14:43.934 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:43.954 UTC [channelCmd] executeJoin -&gt; INFO 002 Successfully submitted proposal to join channel
  ===================== peer0.org2 joined channel 'mychannel' =====================
  
  + peer channel join -b mychannel.block
  + res=0
  + set +x
  2020-02-21 09:14:47.020 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:47.040 UTC [channelCmd] executeJoin -&gt; INFO 002 Successfully submitted proposal to join channel
  ===================== peer1.org2 joined channel 'mychannel' =====================
  
  Updating anchor peers for org1...
  + peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
  + res=0
  + set +x
  2020-02-21 09:14:50.102 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:50.119 UTC [channelCmd] update -&gt; INFO 002 Successfully submitted channel update
  ===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================
  
  Updating anchor peers for org2...
  + peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
  + res=0
  + set +x
  2020-02-21 09:14:53.190 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  2020-02-21 09:14:53.207 UTC [channelCmd] update -&gt; INFO 002 Successfully submitted channel update
  ===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
  
  + peer lifecycle chaincode package mycc.tar.gz --path /opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/abstore/java/ --lang java --label mycc_1
  + res=0
  + set +x
  ===================== Chaincode is packaged on peer0.org1 =====================
  
  Installing chaincode on peer0.org1...
  + peer lifecycle chaincode install mycc.tar.gz
  + res=1
  + set +x
  Error: failed to endorse chaincode install: rpc error: code = Unavailable desc = transport is closing
  !!!!!!!!!!!!!!! Chaincode installation on peer0.org1 has failed !!!!!!!!!!!!!!!!
  ========= ERROR !!! FAILED to execute End-2-End Scenario ===========
  
  ERROR !!!! Test failed
  </code></pre>
  
  <hr>
  
  <p>EDIT 24/02/2020: I brought down the script, killed all active containers and pruned them, then re-ran the script.</p>
  
  <pre><code>CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS              PORTS                                NAMES
  6182b99f3483        hyperledger/fabric-javaenv:2.0      "/bin/sh -c ./build.…"   4 minutes ago       Up 4 minutes                                             suspicious_galileo
  158e8bbd501b        hyperledger/fabric-tools:latest     "/bin/bash"              5 minutes ago       Up 5 minutes                                             cli
  1d4f0e232e58        hyperledger/fabric-peer:latest      "peer node start"        5 minutes ago       Up 5 minutes        0.0.0.0:7051-&gt;7051/tcp               peer0.org1.example.com
  90ba9fb67fae        hyperledger/fabric-orderer:latest   "orderer"                5 minutes ago       Up 5 minutes        7050/tcp, 0.0.0.0:11050-&gt;11050/tcp   orderer5.example.com
  e4f730446f05        hyperledger/fabric-orderer:latest   "orderer"                5 minutes ago       Up 5 minutes        0.0.0.0:7050-&gt;7050/tcp               orderer.example.com
  a9c126e1e280        hyperledger/fabric-orderer:latest   "orderer"                5 minutes ago       Up 5 minutes        7050/tcp, 0.0.0.0:8050-&gt;8050/tcp     orderer2.example.com
  c53240f4d9fe        hyperledger/fabric-peer:latest      "peer node start"        5 minutes ago       Up 5 minutes        7051/tcp, 0.0.0.0:9051-&gt;9051/tcp     peer0.org2.example.com
  7c96596eda01        hyperledger/fabric-peer:latest      "peer node start"        5 minutes ago       Up 5 minutes        7051/tcp, 0.0.0.0:10051-&gt;10051/tcp   peer1.org2.example.com
  4fabd60e9af4        hyperledger/fabric-peer:latest      "peer node start"        5 minutes ago       Up 5 minutes        7051/tcp, 0.0.0.0:8051-&gt;8051/tcp     peer1.org1.example.com
  c5ffe6032bdd        hyperledger/fabric-orderer:latest   "orderer"                5 minutes ago       Up 5 minutes        7050/tcp, 0.0.0.0:10050-&gt;10050/tcp   orderer4.example.com
  04ec9beedce6        hyperledger/fabric-orderer:latest   "orderer"                5 minutes ago       Up 5 minutes        7050/tcp, 0.0.0.0:9050-&gt;9050/tcp     orderer3.example.com
  </code></pre>
  
  <p>The Java container is running properly, but the error still persists.</p>