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

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.

Related

orderer client failed to connect to localhost:10050: failed to create new connection: connection

I am learning Hyperledger Fabric. I have added an org to my application channel. I successfully joined the channel and I am trying to invoke the chaincode.
I am receiving the error:
Error: error getting broadcast client: orderer client failed to connect to localhost:10050: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 127.0.0.1:10050: connect: connection refused"
when I run chaincodeInvoke function:
The content of the function is:
# Create Car
peer chaincode invoke -o localhost:10050 \
--ordererTLSHostnameOverride orderer4.example.com \
--tls $CORE_PEER_TLS_ENABLED \
--cafile $ORDERER_CA \
-C $CHANNEL_NAME -n ${CC_NAME} \
--peerAddresses localhost:7051 \
--tlsRootCertFiles $PEER0_ORG1_CA \
--peerAddresses localhost:9051 --tlsRootCertFiles $PEER0_ORG2_CA \
-c '{"function": "createCar","Args":["Car-1111", "Audi", "R8", "Red", "Pavan"]}'
Thank you for your help
Be sure that your orderer is really running on port 10050. Do a docker ps to check the port number for the container. I presume that you are running docker if you are following the tutorials.
I will also presume that you ran these commands to install the contract code
peer lifecycle chaincode install
peer lifecycle chaincode approveformyorg for both peers
peer lifecycle chaincode commit
If the contract code was installed, there should be other containers listed in your docker ps command to show that they exist.
In my experience, this kind of error has been due to misconfiguration i.e. using an incorrect port number to that defined in the YAML file.

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.

Hyperledger fabric 2.0

Getting the below error while trying to connect peer to channel in hyper-ledger fabric v 2.0 with couchbase 2,3
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.
Can anyone suggest why this is happening?
peer channel create -o localhost:7050 -c mychannel --ordererTLSHostnameOverride orderer.example.com -f ./artifacts/channel/mychannel.tx --outputBlock ./channel-artifacts/mychannel.block --tls true --cafile $ORDERER_CA
try this way to do this

Problem with instantiating chaincode in Hyperledger fabric Network

I have a problem with instantiating chaincode in Hyperledger fabric Network with comm:
peer chaincode instantiate -o orderer.ex.com:7050 -C roaming -n chaincode -v 1.1 -c '{"Args":[]}' -P "AND ('ORG1MSP.member')" --tls --cafile /etc/hyperledger/fabric/config/ca.crt
The peer is joined the channel and chaincode is installed on it.
The log of orderer is:
ERRO 029 TLS handshake failed with error tls: oversized record received with length 64774 server=Orderer
WARN 02a Error reading from 172.16.0.81:34562: rpc error: code = Canceled desc = context canceled
INFO 02b streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.16.0.81:34562 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call
WARN 02c Error reading from 172.16.0.81:35318: rpc error: code = Canceled desc = context canceled
In the log of the peer - nothing interesting.
The error looks like the client is trying to communicate speak HTTP/GRPC to a server expecting HTTPS/GRPCS (or viceversa)
If your fabric network endpoints are not encrypted, remove the --tls and --cafile flags.
Otherwise, make sure to use an encrypted endpoint for the orderer (e.g. orderer.ex.com:443 if it's exposed via HTTPS with an ingress controller) and the peer as well (CORE_PEER_ADDRESS)
I have also found when enabling TLS that the following environment variables are needed in addition to the --tls and --cafile above:
CORE_PEER_TLS_ROOTCERT_FILE=/path/to/ca/pem (e.g. `letsencryptauthorityx3.pem`)
CORE_PEER_TLS_ENABLED=true

Addition of an organization in Hyperledger-fabric blockchain

I am adding new org I am getting this 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
while doing this
peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c
$CHANNEL_NAME --tls --cafile $ORDERER_CA
Error resolved prblem was containers were with different network it works if all the conatiners are in same network

Resources