Hyperledger Fabric issue orderer client failed to connect to orderer xxx net 7050 failed to create new connection

+4 votes

Docker-composer -base.yaml configuration file, where the domain name I marked Mosaic

Cli error log orderer client failed to connect to orderer. XXX: xx:7050: failed to create new connection: context deadline exceeded

peer-base.yaml

docker-compose-orderer.yaml

docker-compose-peer0.yaml

I can communicate with Orderer in cli

The orderer error message log

Yun is running fine, but an error occurred while creating the channel bothered me for a few days, asking the guys for help.

Nov 2, 2018 in Blockchain by gujiwork
• 200 points
11,360 views
Hey @gujiwork! Are you doing this on VM? Could you mention the steps you followed (preferably with the commands)?

I deployed fabric on vm, and I broke all the services up and deployed them independently to each vm.

I started an orderer node, four Peer nodes, and encountered an error when I executed the create channel in the peer0 cli container

The command to create the channe

docker exec -it cli bash

ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/
example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/mychannel.tx --tls --cafile $ORDERER_CA

2 answers to this question.

+3 votes
Best answer

Hey @gujiwork,

Try making the following changes:
docker-compose-base.yaml and docker-compose-orderer:

working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer

volumes:
- ./config/:/etc/hyperledger/configtx 
- ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/:/etc/hyperledger/msp/orderer
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/msp/peerOrg1

docker-compose-peer0.yaml:

Under cli:

command: /bin/bash

And also, the command you are using to create channel is:

peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/mychannel.tx --tls --cafile $ORDERER_CA

You have mentioned in your question

where the domain name I marked Mosaic

so I am guessing your domain name is not orderer.example.com but you are using orderer.example.com:7050 in your command. Try replacing it with your domain.

answered Nov 5, 2018 by Omkar
• 69,130 points

selected Nov 8, 2018 by gujiwork

Thank you. The problem has been solved. Now there is a new error

This indicates success, and the prompt when instantiating chain code:

Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: API error (400): OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"chaincode\": executable file not found in $PATH": unknown

  • The order I executed at peer0

  • # docker exec -it cli bash

    # peer chaincode install -n mycc -v 1.0 -p  github.com/hyperledger/fabric/chaincode/go/example02

    2018-11-06 08:25:20.092 UTC [chaincodeCmd] install -> INFO 051 Installed remotely response:<status:200 payload:"OK" >

    # ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations

    /xxxx.net/orderers/orderer.xxxx.net/msp/tlscacerts/tlsca.xxxx.net-cert.pem

    peer chaincode instantiate -o orderer.xxxx.net:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR    ('Org1MSP.member','Org2MSP.member')"

    Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: API error (400): OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"chaincode\": executable file not found in $PATH": unknown

    Orderer logs

    2018-11-06 17:00:25.126 CST [orderer/common/server] Broadcast -> DEBU 85d Starting new Broadcast handler
    2018-11-06 17:00:25.126 CST [orderer/common/broadcast] Handle -> DEBU 85e Starting new broadcast loop for 192.168.1.218:42194
    2018-11-06 17:00:28.056 CST [orderer/common/broadcast] Handle -> WARN 85f Error reading from 192.168.1.218:42194: rpc error: code = Canceled desc = context canceled
    2018-11-06 17:00:28.056 CST [orderer/common/server] func1 -> DEBU 860 Closing Broadcast stream

When I try to

peer chaincode install -n feiba1 -v 1.0 -p  github.com/hyperledger/fabric/chaincode/go/example02

change to

peer chaincode install -n feiba1-v 1.0 -p  github.com/hyperledger/fabric/chaincode/go/example02/cmd

Execute the instantiated chain code

Error starting chaincode: error trying to connect to local peer: context deadline exceeded

Hey again @gujiwork! 

Try changing 

CORE_PEER_ADDRESS=peer0.org1.XXXX:7051

to

CORE_PEER_ADDRESS=peer0.org1.XXXX:7051 CORE_CHAINCODE_ID_NAME=mycc

If it doesn't work, 

go to the directory: github.com/hyperledger/fabric/chaincode/go/example02

execute: go build

then run:

CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS:peer0.org1.XXXX:7051 ./example02

Also check if commenting out CORE_PEER_LISTENADDRESS works

Seems like GO environment variables are not set right. I'd suggest you uninstall GO and install it again (only changing the environment variables will also work.)

Refer: https://nats.io/documentation/tutorials/go-install/

Then try this:

go to the directory: 

/opt/gopath/src/github.com/hyperledger/fabric/chaincode/go/example02

execute: go build

then run:

CORE_PEER_ADDRESS:peer0.org1.XXXX:7051 ​CORE_CHAINCODE_ID_NAME=mycc:0 ./example02

if it doesnt work, try:

CORE_PEER_ADDRESS:peer:7051 ​CORE_CHAINCODE_ID_NAME=mycc:0 ./example02

if it doesnt work, try:

CORE_PEER_ADDRESS:peer:7052 ​CORE_CHAINCODE_ID_NAME=mycc:0 ./example02

If these do not work, please refer these steps and compare it with what you have done: 

https://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html

Make sure you change the name of directories, and path accordingly. 

change to docker-compose-cli.yaml

- CORE_PEER_ADDRESS=peer0.org1.xxxx.net:7051

- CORE_PEER_ADDRESS=0.0.0.0:7051

Any update on this? Did you find a solution?
Yes, I found a solution.
What solution worked for you?
I defined the network in each peer yaml file and connected to each other through ovarlay , Key parameter external: true



networks:
  HZ-VPC:
    external: true
Since I did not use this parameter before, the default network is automatically created when I start fabric peer

Although I can make network ping Telnet communication through hosts, I cannot instantiate the chain code

I learned from the error that the IP address and my overlay network address were not available, plus the parameter fabric will start when Call external network , And thank you for your help

Any idea why CORE_PEER_ADDRESS=peer0.org1.xxxx.net:7051 was not working?

Have you tried echoing $CORE_PEER_ADDRESS in the container without any output? Or you can set CORE_PEER_ADDRESS = peer0.org1.xxxx.net:7051 directly in the cli container.
Hey.. How did you make the network ping Telnet Communication through hosts? I am not able to find the right steps
You can check if /etc/hosts has the corresponding IP hostname, or you can set docker to the same network, that is, cross-host communication so that they can communicate with each other. The reason I encounter the inability to communicate is usually that the firewall blocks them. Can you post your log information so that I can know the reason more clearly
Thanks @gujiwork! I had followed the same steps but I missed out disabling firewall. Your answer saved me a lot of time. I disabled the firewall and was able to ping. Thanks a ton!!
Hello Sir. Can you please explain what will happen when you echo $CORE_PEER_ADDRESS without any output? I am new to hyperledger and not understanding the logic behind this. Please
+1 vote

Could be due to docker conflicts, remove docker containers with the following command:

$ docker rm -f $(docker ps -aq) && docker rmi -f $(docker images | grep dev | awk '{print $3}') && docker volume prune

Then restart the network:

./byfn.sh down
./byfn.sh generate
./byfn.sh up
answered Apr 23, 2019 by Nick
Hey. This helped solve the error but now I am getting some error related to binaries.
Hey @Guru, could you please mention the error logs?

You can install the binaries as follows @Guru:

Open a terminal and go to the fabric-samples directory and the below command:

curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0
You're the man...!!

Thanks Nick

Related Questions In Blockchain

+2 votes
3 answers

Hyperledger Fabric: Peer Connection error: Failed obtaining connection: Could not connect to any of the endpoints.

 You can extend your /etc/hosts file and make orderer.example.com domain name ...READ MORE

answered Nov 13, 2018 in Blockchain by Omkar
• 69,130 points
2,358 views
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,700 points
302 views
0 votes
2 answers
+2 votes
4 answers

"failed to create new connection context deadline exceeded." error in Hyperledger Fabric

Try remove previous docker containers(have mentioned the ...READ MORE

answered Apr 23, 2019 in Blockchain by Kiran
7,904 views