6londe
6londe

Reputation: 557

Hyperledger-fabric : chaincode deploy connection error

I'm trying to test fabric chaincode example02, with docker. I'm newbie :)

This is my docker-compose.yml :

membersrvc:
  image: hyperledger/fabric-membersrvc
  command: membersrvc

vp0:
  image: hyperledger/fabric-peer
  environment:
    - CORE_PER_ID=vp0
    - CORE_PEER_ADDRESSAUTODETECT=true
    - CORE_VM_ENDPOINT=http://0.0.0.0:2375
    - CORE_LOGGING_LEVEL=DEBUG
  command: sh -c "sleep 5; peer node start --peer-chaincodedev"

vp1:
  extends:
    service: vp0
  environment:
    - CORE_PEER_ID=vp1
    - CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
  links:
    - vp0

vp2:
  extends:
    service: vp0
  environment:
    - CORE_PEER_ID=vp2
    - CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
  links:
    - vp0

and I run (I refered to Fabric chaincode setup page):

Terminal 1 :

$ docker-compose up

Terminal 2 :

$ cd /hyperledger/examples/chaincode/go/chaincode_example02

$ CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7051 ./chaincode_example02

Terminal 3 :

$ peer chaincode deploy -n mycc -c '{"Args": ["init", "a","100", "b", "200"]}'

It works well in terminal 1,2. But terminal 3 shows connection error.

2016/10/21 04:39:15 grpc: addrConn.resetTransport failed to create client
transport: connection error: desc = "transport: dial tcp 0.0.0.0:7051:
getsockopt: connection refused"; Reconnecting to {"0.0.0.0:7051" <nil>}
Error: Error building chaincode: Error trying to connect to local peer: 
grpc: timed out when dialing

What's the problem?

Upvotes: 0

Views: 2872

Answers (1)

Clyde D&#39;Cruz
Clyde D&#39;Cruz

Reputation: 2065

It seems you are missing the compose statements to map the required ports from the docker container to the host machine (where you are trying out the peer command ). So its possible that the peer process is listening on port 7051 inside your peer docker container, but this connection is not available to the peer command used outside of this container in terminal 3.

You can map ports using the 'ports' tag. eg:

membersrvc:
  image: hyperledger/fabric-membersrvc
  ports:
    - "7054:7054"
  command: membersrvc

vp0:
  image: hyperledger/fabric-peer
  ports:
    - "7050:7050"
    - "7051:7051"
    - "7053:7053"
  environment:
    - CORE_PER_ID=vp0
    - CORE_PEER_ADDRESSAUTODETECT=true
    - CORE_VM_ENDPOINT=http://0.0.0.0:2375
    - CORE_LOGGING_LEVEL=DEBUG
  command: sh -c "sleep 5; peer node start --peer-chaincodedev"

Before you do peer chaincode deploy ...in terminal 3, you can check if a the peer process is listening on port 7051 using

netstat -lnptu |grep 7051

Upvotes: 3

Related Questions