failed Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054] | ca_peerOrg1 and ca_peerOrg2 is not running

failed Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054] | ca_peerOrg1 and ca_peerOrg2 is not running

我正在尝试 运行 使用容器的 hyperledger fabric。这是我的 docker-compose yml。 docker-compose.yaml

version: '2'

services:

  ca.org1.sample.com:
    image: hyperledger/fabric-ca:1.4
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org1
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.sample.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/0c7af57d616f614fd42250b8ba14a0c777220874d328ecbd1464a47ef3f85b1a_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.sample.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/0c7af57d616f614fd42250b8ba14a0c777220874d328ecbd1464a47ef3f85b1a_sk
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
    volumes:
      - ./channel/crypto-config/peerOrganizations/org1.sample.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg1

  ca.org2.sample.com:
    image: hyperledger/fabric-ca:1.4
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org2
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.sample.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/fc399b786271e773cc0011593c6bcae7c4b4ae0f4a595ebf0883154bddb4daa7_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.sample.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/fc399b786271e773cc0011593c6bcae7c4b4ae0f4a595ebf0883154bddb4daa7_sk
    ports:
      - "8054:7054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
    volumes:
      - ./channel/crypto-config/peerOrganizations/org2.sample.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg2

  orderer.sample.com:
    container_name: orderer.sample.com
    image: hyperledger/fabric-orderer:1.4
    environment:
      - FABRIC_LOGGING_SPEC=debug
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/crypto/orderer/msp
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/crypto/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/crypto/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/crypto/orderer/tls/ca.crt, /etc/hyperledger/crypto/peerOrg1/tls/ca.crt, /etc/hyperledger/crypto/peerOrg2/tls/ca.crt]
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderers
    command: orderer
    ports:
      - 7050:7050
    volumes:
        - ./channel:/etc/hyperledger/configtx
        - ./channel/crypto-config/ordererOrganizations/sample.com/orderers/orderer.sample.com/:/etc/hyperledger/crypto/orderer
        - ./channel/crypto-config/peerOrganizations/org1.sample.com/peers/peer0.org1.sample.com/:/etc/hyperledger/crypto/peerOrg1
        - ./channel/crypto-config/peerOrganizations/org2.sample.com/peers/peer0.org2.sample.com/:/etc/hyperledger/crypto/peerOrg2

  peer0.org1.sample.com:
    container_name: peer0.org1.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org1.sample.com
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_ADDRESS=peer0.org1.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.sample.com:7051
    ports:
      - 7051:7051
      - 7053:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org1.sample.com/peers/peer0.org1.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

  peer1.org1.sample.com:
    container_name: peer1.org1.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org1.sample.com
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_ADDRESS=peer1.org1.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.sample.com:7051
    ports:
      - 7056:7051
      - 7058:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org1.sample.com/peers/peer1.org1.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

  peer0.org2.sample.com:
    container_name: peer0.org2.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org2.sample.com
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_ADDRESS=peer0.org2.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.sample.com:7051
    ports:
      - 8051:7051
      - 8053:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org2.sample.com/peers/peer0.org2.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

  peer1.org2.sample.com:
    container_name: peer1.org2.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org2.sample.com
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_ADDRESS=peer1.org2.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.sample.com:7051
    ports:
      - 8056:7051
      - 8058:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org2.sample.com/peers/peer1.org2.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

base.yaml 文件

version: '2'
services:
  peer-base:
    image: hyperledger/fabric-peer:1.4
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=artifacts_default
      - FABRIC_LOGGING_SPEC=ERROR
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/crypto/peer/msp
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/crypto/peer/tls/server.key
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/crypto/peer/tls/server.crt
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/crypto/peer/tls/ca.crt
    logging:
      driver: "json-file"
      options:
        max-file: "2"
        max-size: "5m"
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    volumes:
        - /var/run/:/host/var/run/

在 运行ning 这些容器之后,我看不到 运行ning ca_peerOrg1 and ca_peerOrg2 个容器。

➜  sample_network git:(master) ✗ docker container ps
CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS              PORTS                                            NAMES
17e106be6872        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp   peer0.org2.sample.com
fd72c0b378e3        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.sample.com
f0198beef653        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:7056->7051/tcp, 0.0.0.0:7058->7053/tcp   peer1.org1.sample.com
a9d2a0fabe6d        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:8056->7051/tcp, 0.0.0.0:8058->7053/tcp   peer1.org2.sample.com
8173c3c09e6a        hyperledger/fabric-orderer:1.4   "orderer"           49 seconds ago      Up 43 seconds       0.0.0.0:7050->7050/tcp                           orderer.sample.com

这里ca_peerOrg1和ca_peerOrg2不是运行ning。所以当我尝试从节点 sdk 注册时,出现以下错误,

POST request Enroll on Org1  ...

{"success":false,"message":"failed Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]"}

ORG1 token is null

POST request Enroll on Org2 ...

{"success":false,"message":"failed Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:8054]"}

ORG2 token is null

请帮我解决这个问题。

检查各组织CA的FABRIC_CA_SERVER_CA_KEYFILEFABRIC_CA_SERVER_TLS_KEYFILE是否写对了。在 docker-compose.yaml

# ca_peerOrg1
ls ./channel/crypto-config/peerOrganizations/org1.sample.com/ca/

# ca_peerOrg2
ls ./channel/crypto-config/peerOrganizations/org2.sample.com/ca/

上述命令操作的结果值中,*_sk文件的名字应该写成FABRIC_CA_SERVER_CA_KEYFILEFABRIC_CA_SERVER_TLS_KEYFILE

如果有日志照,我可以讲的更清楚。

docker logs ca_peerOrg1
docker logs ca_peerOrg2