简体   繁体   中英

Docker image is created, however container fails to launch on instantiating the chaincode in Hyperledger Fabric using Java-SDK

On instantiating the chaincode using java-sdk , the docker image for the container is created. However the chaincode container fails to launch with below logs.

2018-11-08 07:05:20.774 UTC [shim] userChaincodeStreamGetter -> ERRO 001 context deadline exceeded
error trying to connect to local peer
github.com/hyperledger/fabric/core/chaincode/shim.userChaincodeStreamGetter
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/chaincode.go:112
github.com/hyperledger/fabric/core/chaincode/shim.Start
    /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/chaincode.go:151
main.main
    /chaincode/input/src/github.com/fabcar/fabcar.go:200
runtime.main
    /opt/go/src/runtime/proc.go:198
runtime.goexit
    /opt/go/src/runtime/asm_amd64.s:2361
Error creating new Smart Contract: error trying to connect to local peer: context deadline exceeded%

Peer is launched using docker-compose.yaml in swarm mode as a stack.

  peer0org1:
    image: hyperledger/fabric-peer:1.2.0
    deploy:
      placement:
        constraints:
          - node.role == manager
          - node.id == vbka1smkqlqflno3hfp69rbr7
    environment:
      - CORE_PEER_ID=peer0.org1.example.com
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_ADDRESS=peer0org1:7051
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
      - CORE_VM_ENDPOINT=http://10.80.102.27:4243
      - CORE_LOGGING_LEVEL=DEBUG
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0org1:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0org1:7051
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/crypto/peer/msp
      - CORE_PEER_TLS_ENABLED=false
      - 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
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    volumes:
        - /var/run/:/host/var/run/
    ports:
      - 7051:7051
      - 7052:7052
      - 7053:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer
    networks:
      - networky

SDK Logs:

INFO: fabcar- Chain code instantiation response {
  status: 500
  message: "failed to execute transaction Tx_ID:timeout expired while starting chaincode fabcar:1 for transaction Tx_ID"
}

Your chaincode container is not able to communicate with the peer. You need to set the CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE environment variable (or vm.docker.hostConfig.NetworkMode in core.yaml) for your peer(s) to the name of the Docker overlay network used by your Swarm cluster. You also need to mark that network as attachable as well else the chaincode containers will not be able to connect on the overlay network. The Docker Compose docs for using Swarm Mode have a section on the relevant parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM