I am learning how to use Hyperledger fabric and Chaincode. Basically, I followed this link to create a Java chain code in Hyperledger fabric, but I can't invoke my chain code in the cli/channel.
I used BYFN.sh
from Hyperledger fabric official guide to building up the fabric network and followed the blog to make Gradle & Java Chaincode.
After I tried to invoke it with
peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["createWallet","tom","100"]}'
I got this error:
Error: error getting endorser client for invoke: endorser client failed to connect to peer0.org2.example.com:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.21.0.4:7051: connect: connection refused"
It would be very helpful if someone can point a direction and tell me what might possibly be wrong. I tried to google it but I could not find any useful information.
update:
Turns out it is a port number issue. I went into one of the peer's container and turns out that the port number is 9051 instead of 7051. So I change the port number in the chaincode invoke command and everything works fine.