hyperledger fabric sdk节点订购者,节点客户端在截止日期之前无法连接

时间:2019-03-23 09:01:07

标签: node.js hyperledger-fabric hyperledger

我正在使用架构示例项目“基本网络”作为实现环境,以基于架构节点客户端sdk开发链代码和nodejs客户端应用程序(REST API),该节点应用程序与架构对等方驻留在同一主机中。 虽然所有docker容器(ca,orderer,peer,couchdb,client)都位于一个主机中,但我已经成功创建并加入通道,安装和实例化链码,因此使用nodejs client时,查询和调用功能成功完成。 connection.json文件是从基本网络示例复制而来的。 当我将订购者容器移动到另一台主机,修改了容器docker-compose yaml文件,以及connection.json时,客户端容器中的操作结果未更改,它们都没问题,nodejs客户端应用程序查询操作可以继续,但是调用(插入和修改)失败,日志为:

2019-03-23T03:32:38.769Z - debug: [Remote.js]: getUrl::grpc://192.168.122.6:7050
2019-03-23T03:32:38.769Z - error: [Remote.js]: Error: Failed to connect before the deadline URL:grpc://192.168.122.6:7050
2019-03-23T03:32:38.770Z - error: [Remote.js]: Error: Failed to connect before the deadline URL:grpc://192.168.122.6:7050
2019-03-23T03:32:38.772Z - debug: [Remote.js]: getUrl::grpc://192.168.122.6:7050
2019-03-23T03:32:38.772Z - error: [Orderer.js]: Orderer grpc://192.168.122.6:7050 has an error Error: Failed to connect before the deadline URL:grpc://192.168.122.6:7050 
2019-03-23T03:32:38.772Z - error: [Orderer.js]: Orderer grpc://192.168.122.6:7050 has an error Error: Failed to connect before the deadline URL:grpc://192.168.122.6:7050 

这里,“ 192.168.122.6”是订购者容器所在的主机。下面是nodejs应用程序使用的connection.json文件,我已关闭了订购者和对等方之间的tls:

{
"name": "basic-network",
"version": "1.0.0",
"client": {
    "organization": "Org1",
    "connection": {
        "timeout": {
            "peer": {
                "endorser": "300"
            },
            "orderer": "300"
        }
    }
},
"channels": {
    "mychannel": {
        "orderers": [
            "orderer.example.com"
        ],
        "peers": {
            "peer0.org1.example.com": {}
        }
    }
},
"organizations": {
    "Org1": {
        "mspid": "Org1MSP",
        "peers": [
            "peer0.org1.example.com"
        ],
        "certificateAuthorities": [
            "ca.example.com"
        ]
    }
},
"orderers": {
    "orderer.example.com": {
        "url": "grpc://192.168.122.6:7050"
    }
},
"peers": {
    "peer0.org1.example.com": {
        "url": "grpc://127.0.0.1:7051"
    }
},
"certificateAuthorities": {
    "ca.example.com": {
        "url": "http://127.0.0.1:7054",
        "caName": "ca.example.com"
    }
}

}

我想,connection.json中出了点问题,但是我不知道是哪儿。 以下是docker-compose.yaml中有关定购者和同伴的内容:

  orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer
environment:
  - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_basic
  - ORDERER_GENERAL_LOGLEVEL=info
  - FABRIC_LOGGING_SPEC=info
  - 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/msp/orderer/msp
  - ORDERER_GENERAL_TLS_ENABLED=false
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
  - 7050:7050
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
networks:
  - basic


peer0.org1.example.com:
    container_name: peer0.org1.example.com
    image: hyperledger/fabric-peer
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
      - CORE_PEER_NETWORKID=basic
      - CORE_PEER_ID=peer0.org1.example.com
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:7052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.zte.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.zte.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #  the following setting starts chaincode containers on the same
      #  bridge network as the peers
      #  https://docs.docker.com/compose/networking/
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=net_basic
      - FABRIC_LOGGING_SPEC=debug
      - CORE_CHAINCODE_LOGGING_LEVEL=debug
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
      - CORE_PEER_TLS_ENABLED=false
      - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=false
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: peer node start
    # command: peer node start --peer-chaincodedev=true
    ports:
      - 7051:7051
      - 7052:7052
      - 7053:7053
    volumes:
        - /var/run/:/host/var/run/
        - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer
        - ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
        - ./config:/etc/hyperledger/configtx
    depends_on:
    #  - orderer.example.com
      - couchdb
    networks:
      - basic
    extra_hosts:
      - "orderer.example.com:192.168.122.6"
      - "peer0.org1.example.com:127.0.0.1"

0 个答案:

没有答案