问题
I am trying run two org example on tow different nodes acting as Org1 and Org2. I am able to query chaincode. Next I tried installing composer over it. All the steps were successful except when I tried pinging the network. It gave me ENDORSEMENT_POLICY_FAILURE error. For Org1-only and Org2-only connection profiles I have used localhost only. Moreover even though there is endorsement failure error, I can see using blockchain explorer and in logs blocks getting generating using ping command in both the machines. Org1 connection profile is given below:
{
"name": "byfn-network-org1",
"type": "hlfv1",
"mspID": "Org1MSP",
"peers": [
{
"requestURL": "grpcs://localhost:7051",
"eventURL": "grpcs://localhost:7053",
"cert": "/home/user/fabric-samples/multi-org-multi-node/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
"hostnameOverride": "peer0.org1.example.com"
},
{
"requestURL": "grpcs://localhost:8051",
"eventURL": "grpcs://localhost:8053",
"cert": "/home/user/fabric-samples/multi-org-multi-node/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
"hostnameOverride": "peer1.org1.example.com"
},
{
"requestURL": "grpcs://<PC2-IP>:9051",
"cert": "/home/user/fabric-samples/multi-org-multi-node/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt",
"hostnameOverride": "peer0.org2.example.com"
},
{
"requestURL": "grpcs://<PC2-IP>:10051",
"cert": "/home/user/fabric-samples/multi-org-multi-node/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt",
"hostnameOverride": "peer1.org2.example.com"
}
],
"ca": {
"url": "https://localhost:7054",
"name": "ca-org1",
"cert": "/home/user/fabric-samples/multi-org-multi-node/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
"hostnameOverride": "ca.org1.example.com"
},
"orderers": [
{
"url" : "grpcs://localhost:7050",
"cert": "/home/user/fabric-samples/multi-org-multi-node/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt",
"hostnameOverride": "orderer.example.com"
}
],
"channel": "mychannel",
"timeout": 300
}
Orderer is on PC 1 so I used localhost
回答1:
The Connection Profiles are used by Composer to connect to the Peer Containers etc, but the Peer Containers (and the Orderer) need to communicate too. So you need to have address resolution within the Containers.
When you follow the MultiOrg tutorial on a single Machine docker-compose creates a dedicated network bridge that allows all the containers to address and communicate with eachother by fqdn. When you separate out to 2 Machines you need to manage that. The extra_hosts
feature of Docker Compose can help but there are still issues of ports to manage.
The real solution for inter-communicating docker containers on separate machines is to use Kubernetes or Docker Swarm.
来源:https://stackoverflow.com/questions/49366032/endorsement-policy-failure-error-hyperledger-composer