At the time of chaincode instansiate getting error Error: could not send: rpc error: code = Unavailable desc = transport is closing - hyperledger-fabric

Using Linux 16.04 and docker All the containers are running fine .Successfully installed the chaincode on core peer.
But At the time of chaincode instansiate
peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n fabcar -l "golang" -v 1.0 -c '{"Args":[""]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
Geeting error
`Error: could not send: rpc error: code = Unavailable desc = transport is closing`
Thanks in advance.

I was facing this issue because I enabled tls on the peer but not providing the tls and ca file to the orderer at the time of chaincode instantiate.

This may work:
Bring down the network
Disable TLS in below files by commenting environment variables listed below.
base/docker-compose-base.yaml
base/peer-base.yaml
docker-compose-cli.yaml:
docker-compose-e2e-template.yam
ENV:
CORE_PEER_TLS_ENABLED
CORE_PEER_TLS_CERT_FILE
CORE_PEER_TLS_KEY_FILE
CORE_PEER_TLS_ROOTCERT_FILE
Bring up the network
Another way is to pass TLS certificate as an argument to peer fetch channel command.

Related

Technical Question - Hyperledger Fabric - Error: error getting endorser client for invoke: endorser client > failed to connect to

I am unsure of this is suitable for this forum as this is a technical question. I will add it anyway to see if anyone has any technical skills here.
I am running fabcar from Hyperledger Fabric 2.0 and the invoke works from the invoke.js program but fails using the CLI and peer chaincode. I have tried a few combinations without any success.
The command -
peer chaincode invoke -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile ~/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles ~/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles ~/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -C mychannel -n fabcar -c '{"Args":["createCar","CAR300", "VW", "Polo", "Grey", "Mary"]}'
Error -
Error: error getting endorser client for invoke: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp: lookup peer0.org1.example.com: no such host"
Docker containers:
86b85d99b510/dev-peer0.org2.example.com-fabcar_4-2561b83e10218324c7c566345c50373c5f0b501c961992264dc7fa321eaa5f7f/
f0725155e976/dev-peer0.org1.example.com-fabcar_4-2561b83e10218324c7c566345c50373c5f0b501c961992264dc7fa321eaa5f7f/
e2e33a38f61b/peer0.org2.example.com/7051/tcp, 0.0.0.0:9051->9051/tcp
a59f7011af8c/peer0.org1.example.com/0.0.0.0:7051->7051/tcp
f395bed7101d/couchdb1/4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp
b3b7b94ed872/couchdb0/4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp
db56371abe59/orderer.example.com/0.0.0.0:7050->7050/tcp
ddcabab0b13c/ca_org2/7054/tcp, 0.0.0.0:8054->8054/tcp
d7b2bd0a94bc/ca_orderer/7054/tcp, 0.0.0.0:9054->9054/tcp
e0e300be2273/ca_org1/0.0.0.0:7054->7054/tcp
This situation is happened because you called a gRPC to peer server but your call failed to hit the server. This situation may happen for many reasons, but for most of the cases the situation is happened due to server down(peer server exit or down due to misconfiguration) or for wrong certificate or your call failed to hit the server due to misconfiguration.
Use "docker container ls -a" to see all containers including the exited one.

I'm trying to instantiate a chaincode wriiten in node.js on the hyperledger fabric but I'm getting error

I installed the chaincode on the network but when I'm trying to instantiate,
I'm getting :
"Error: error getting broadcast client: orderer client failed to connect to 127.0.0.1:7050: failed to create new connection: context deadline exceeded"
Also, I tried to add TLS but then I get the following error:
Error: error getting broadcast client: failed to load config for OrdererClient: unable to load orderer.tls.rootcert.file:
And, the orderer logs are:
My orderer TLS is enabled now:
I'll be glad if someone can help or guide me atleast, I'm new to HyperledgerFabric.Thank you.
Adapt to your case:
peer chaincode instantiate -n mychannel -v 1.0 -C petshop -c '{"Args":[""]}' -o 127.0.0.1:7050 --tls --cafile /path/to/orderer/tls/ca.pem
Check the "orderer" logs precisely at the time you are instantiating the chaincode (first without TLS and then with TLS). You can see that time from your command-line when you are running that command.
Update your question with that section of orderer logs.
Also, if I need to guess from your current orderer nodes, you might not have enabled TLS for the orderer container.

RPC error "transport is closing" during peer channel fetch

I have a problem with BYFN in Hyperledger Fabric 1.4.3.
I ran byfn.sh generate and byfn.sh up without problems
I need to fetch a block. When I run this command:
peer channel fetch newest mychannel.block -c mychannel --orderer orderer.example.com:7050
from docker cli bash, I get the following error:
error receiving: rpc error code = unavailable desc = transport is closing
How to fix this?

How to run Hyperledger Fabric Network on local machine?

I am trying to run a sample Hyperledger Fabric network without using docker and trying to create channel by following this tutorial.
orderer is running normally in terminal window 1 and is ready to serve requests as you can see in image: here
peer is also running normally in terminal window 2 :
here
Now, when I try to create a channel and run below command from terminal window 3 :
./peer channel create -o localhost:7050 -c mychannel
-f ./channel-artifacts/channel.tx
--tls true
--cafile
./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
It gives following error :
Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded
orderer.example.com is likely not a known host on your local machine. You'll need to create an entry in your /etc/hosts file which maps orderer.example.com to either the IP address of the host or the loopback address 127.0.0.1.
For example:
127.0.0.1 localhost orderer.example.com

Why peer chaincode instantiate execuate many times successfully

I could execute peer chaincode instantiate many times successfully, it should returns it exist, but no. why?
logs after instantiate command
logs the docker returns
steps:
from my github project chaincode-docker-devmode, I copy msp (peer and orderer use together) 、genesis.block、helloch.tx、docker-compose-with-couch.yaml and so on form other place,it should be ok. When I execute :
docker-compose -f docker-compose-with-couch.yaml up
peer、orderer、couchdb0、cli start and then cli execute script.sh
#script.sh content
peer channel create -c helloch -f helloch.tx -o orderer:7050
peer channel join -b helloch.block
then I simulate cli enviroment using terminal at chaincode-docker-devmode current path by following:
#cli simulation, $pwd is the chaincode-docker-devmode path
export CORE_VM_ENDPOINT=unix:///var/run/run/docker.sock
export CORE_LOGGING_LEVEL=DEBUG
export CORE_PEER_ID=cli
export CORE_PEER_ADDRESS=127.0.0.1:7051
export CORE_PEER_LOCALMSPID=DEFAULT
export CORE_PEER_MSPCONFIGPATH=$pwd/msp
bash
When I execute peer channel list It could shows I have join helloch
channel. Then I execute :
peer chaincode install -n hello -v 1.0 -l java -p chaincode/hsl-hsl-user-guide-examples-v14/mytest
peer chaincode instantiate -o 127.0.0.1:7050 -C helloch -n hello -v 1.0 -l java -c "{\"Args\":[\"init\",\"a\", \"100\", \"b\",\"100\"]}"
But I can instantiate many times and the log does not return error as same as above instantiate logs, actually it does not instantiate successfully, why?
Instantiate of the chaincode is essentially a transaction, therefore it has to be endorsed, ordered and committed to take effect. Now in your case peer cli instantiate command succeeds since the transaction proposal successfully endorsed and signed proposal submitted to the ordering service. While based on the following log output:
peer | 2017-09-05 01:09:23.650 UTC [ConnProducer] NewConnection -> ERRO 6da Failed connecting to 127.0.0.1:7050 , error: context deadline exceeded
peer | 2017-09-05 01:09:23.650 UTC [deliveryClient] connect -> ERRO 6db Failed obtaining connection: Could not connect to any of the endpoints: [127.0.0.1:7050]
Peer cannot get connected to the ordering service endpoint which in your case configured to be 127.0.0.1:7050, therefore eventually instantiate transaction is not committed. Therefore you do able to execute the instantiate command again, since no instantiate transaction record exists on the peer ledger from your previous attempt.
You need to change ordering service endpoint from 127.0.0.1:7050 to orderer:7050 and retry your experiment. This value configured inside configtx.yaml file, e.g.:
Orderer: &OrdererDefaults
# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: solo
Addresses:
- orderer:7050
In my case, this was giving me trouble because I did not give the instantiation process enough time before calling an invoke/query transaction.
Try adding a sleep command between your instantiate and invoke/query transaction:
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n fabcar -l "$LANGUAGE" -v 1.0 -c '{"Args":[""]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
# Sleeping to allow time for chaincode to instantiate on peers
sleep 30
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n fabcar -c '{"function":"initLedger","Args":[""]}'
This only applies in the case that you are running a "startup" script in a CLI container of some sort. In my case, I have script.sh which runs when I first bring the network up.
You can instantiate a chaincode with same name only once.
peer channel create -c helloch -f helloch.tx -o 127.0.0.1:7050
after above, you could see the helloch.block detail message by command
configtxgen --inspectBlock helloch.block
It shows
"OrdererAddresses": {
"Version": "0",
"ModPolicy": "/Channel/Orderer/Admins",
"Value": {
"addresses": [
"127.0.0.1:7050"
]
}
},
it seems that the connected orderer address which in helloch.block(channel configuration) comes from genesis.block (which generate from configtx.yaml )

Resources