Error: error getting broadcast client: orderer client failed to connect to orderer.example.com:7050

When $ peer chaincode invoke -C mychannel -n food -c '{"Args":["userRegister","haha","haha"]}'an error occurs during runtime ,Error: error getting broadcast client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded

Use the docker ps -a command to check that the orderer is clearly open.
The problem is that when you execute the invoke command, you need to specify the following things before they can be written into the ledger!
My solution is:
run $ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n food --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"Args":["userRegister","haha","haha"]}'and succeed.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44029550/article/details/114441355