0

I'm working with the "first-network" example of the Hyperledger Fabric framework as found here, but I am not able to successfully instantiate a custom Java chaincode file. Here is the command I am running, which is a very-slightly modified version of the command that the successful start script runs:

peer chaincode instantiate -o orderer.example.com:7050 --tls false --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 mychannel -n javacc -l java -v 1.4 -c '{"Args":["init","a","{10}","b","{20}"]}' --connTimeout 600s -P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'

When I run this command, I get the following error:

Error: error getting broadcast client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded

After some Googling, the error seems fairly straightforward: for some reason the client container I'm using isn't able to connect to my orderer container. However, this doesn't make sense to me for the following reasons:

First: I was successfully able to run ./byfn.sh up -v -c mychannel -s couchdb, which initially installed and instantiated some golang chaincode from the client container with the following commands (the -v 1.0 was later upgraded by the byfn.sh script to version 1.4):

peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
peer chaincode instantiate -o orderer.example.com:7050 --tls false --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 mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'

Second: I was successfully able to install (though not instantiate) my custom Java chaincode from within the same client container: peer chaincode install -n javacc -v 1.4 -l java -p /chaincode-application (/chaincode-application is the location of my Java chaincode source)

I have examined a few possible avenues so far. The website mentioned above does have a note about the length of time: "Please note, Java chaincode instantiation might take time as it compiles chaincode and downloads docker container with java environment." Therefore, I used the --connTimeout 600s (600 seconds = 10 minutes) as part of my command, but I still get the error after waiting for the specified amount of time. Besides, would it really take that long inside of a peer container when it takes about 3 seconds to build in my local IntelliJ?

I have also tried hitting the orderer node from inside my client container: root@7bbadf11e755:/opt/gopath/src/github.com/hyperledger/fabric/peer# curl orderer.example.com:7050, which fails with the following message: curl: (56) Recv failure: Connection reset by peer. This seems to indicate that my client container can connect to the orderer container, but the orderer container doesn't know how to handle the empty request path. As far as I know this is to be expected, likely meaning that the issue isn't in my Docker Compose setup. The only thing I have changed in my Docker Compose files is turning off TLS.

Finally, I've also followed the example Maven project setup for the custom Java chaincode file located inside of my client. I have a pom.xml file that specifies my main class name, and a few Java source files inside of a 'src' directory, including a Java class that implements the proper Chaincode interface as specified in Hyperledger Fabric's documentation. These files build just fine when I run the build with maven outside of the container.

Interestingly, I see the following message on only one of the peer nodes:

2019-04-11 02:11:36.056 UTC [endorser] callChaincode -> INFO 119 [][dc951a0d] Entry chaincode: name:"cscc" 
2019-04-11 02:11:36.060 UTC [endorser] callChaincode -> INFO 11a [][dc951a0d] Exit chaincode: name:"cscc"  (3ms)
2019-04-11 02:11:36.060 UTC [comm.grpc.server] 1 -> INFO 11b unary call completed {"grpc.start_time": "2019-04-11T02:11:36.055Z", "grpc.service": "protos.Endorser", "grpc.method": "ProcessProposal", "grpc.peer_address": "172.27.0.11:42744", "grpc.code": "OK", "grpc.call_duration": "5.7837ms"}

The other peer node has no entry from today, and neither does the orderer node, which I find curious.

I've tried Googling around for the error. I did find this issue, which seems to be exactly my problem, but there is only one answer that doesn't solve the problem and I'm not allowed to comment or vote it up. I also found this, but wasn't able to glean any insights into my own issue since I'm running all of the Hyperledger Fabric nodes locally. I'm out of ideas for how to troubleshoot this issue. Does anyone have any idea why I'm still getting the 'context deadline exceeded' message?

mgh14
  • 3
  • 1
  • 3

1 Answers1

0

I re-enabled TLS in my network and the error went away (another error occurred instead, but that's outside the scope of my question :) ). It seems that maybe I didn't disable all the TLS settings like I thought.

Thanks to @Gari Singh for putting me on the right track!

mgh14
  • 3
  • 1
  • 3