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

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.

Related

Hyperledger Fabric, javascript fabcar chaincode error. Transport: error while dialing: dial tcp 127.0.0.1:7051: connect: connection refused

I am having the same problem with Hyperledger fabric 2.1.1, but I am able to run test network with default options, but when I try to run Fabcar javascript chaincode I get an error:
Error: error getting endorser client for channel: endorser client failed to connect to localhost:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 127.0.0.1:7051: connect: connection refused"
I have tried everything mentioned in thread Error deploying Fabric test-network fabcar chaincode, removed docker images, ran prune, removed organizations data and fired ./network.sh up createChannel -ca -c mychannel -s couchdb -i 2.1.1, but the error is still there. Also, my RAM is 16Gb, so the problem is not there. Any other suggestion, please ?
This situation is happened because you called a gRPC to 127.0.0.1:7051 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(server exit or down due to misconfiguration) or for wrong certificate or your call failed to hit the server due to misconfiguration.
Please check the following docker container and ensure that is running properly.

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.

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?

Hyperledger build network - cannot create peer channel

I'm currently following hyperledger fabric document v1.4.6 to build first network(https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html#manually-generate-the-artifacts)
I first put the network down with ./byfn.sh down then tried creating the network.
However, when i go into docker cli and perform
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
this creates a error saying
InitCmd -> ERRO 001 Cannot run peer because cannot init crypto, folder "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" does not exist
So I tried again with network up (./byfn.sh up) now with the same procedure it creates different error saying
Error: got unexpected status: BAD_REQUEST -- error applying config update to existing channel 'mychannel': error authorizing update: error validating ReadSet: proposed update requires that key [Group] /Channel/Application/Org1MSP be at version 0, but it is currently at version 1
at the same command
First, I'm not sure whether I should be having the network up or down and second how to fix the problem.
Thank you
If you want to perform the manual steps, you need to start from here (with any previous fabric networks down/removed) and follow all the steps in the order as listed on that page.

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

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.

Resources