Lab 4 error during chaincode instantiation

Under Lab 4 on page 27 of the booklet with all the labs when I enter in this command:
peer chaincode instantiate -n ccForAll -v 1.0 -o \
orderer.example.com:7050 -C allarewelcome \
-c '{"Args":["Mach","50"]}'
I get this error:
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: API error (404): network _basic not found
I believe it is because The COMPOSE_PROJECT_NAME variable is not set and it defaults in a blank string giving us a empty space " " appended to "_basic"
When using the command:
docker network ls
I see a network named "startfiles_basic" but when I try to change the COMPOSE_PROJECT_NAME to startfiles or if I just try to change the entire** CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE** variable in the **docker-compose.yml **file to "startfiles_basic" it is still giving me the same error.
Has anyone else come across this error and if so how were you able to solve it?
Thanks.
Comments
Hi!
I could do for peer 0, but not for peer 1. I also looked into this problem you mentioned. I realized the environment variable was empty and is not addressed in the docker-compose.yaml. Also, we can see that the docker-compose.yaml file defines a network called just "basic". So I made everybody inside a basic network. Probably that helped with peer 0.
But now I have been facing this problem when installing the chaincode on peer 1:
Error: error getting endorser client for install: endorser client failed to connect to peer1.org1.example.com:8051: failed to create new connection: context deadline exceeded
Looks like a network problem, but also could be a problem with permission. If it is a problem with permission, we need to look into the relation between identities, roles and permissions on the genesis block. That's my guess.
Let me know if you progressed on this.
Thanks!
@PallabPaul I too had the same problem. but exporting that COMPOSE_PROJECT_NAME solved the same. For your case, did you check
docker logs peer0.org1.example.com
? Did you ensure that, chain code is installed on peer0?@hanesoliveira One thing tha caught my eyes is the port
8051
, shouldn't you be using always7051
inside the container?Hi @maniankara!
I configured the container to have port 8051 externally and 7051 internally. However, you pointed out something that reminded me that since we are shooting commands from the cli container, then we are already inside the Docker internal network meaning that I should use the internal port.
I'll try it again today and let you know. Thanks for the clarification!
Hi @Hanesoliveira
If you are still encountering an error, could you please post the full content of the Docker logs for the orderer node please so I can read it and provide an answer?
Hi @kmyatt, thanks for reaching out!
I could fix it and install the codes, but I am getting an error when instantiating. I am working on that now:
2019-05-29 21:29:59.984 UTC [orderer.common.broadcast] Handle -> WARN 007 Error reading from 172.18.0.6:35118: rpc error: code = Canceled desc = context canceled
2019-05-29 21:29:59.984 UTC [comm.grpc.server] 1 -> INFO 008 streaming call completed {"grpc.start_time": "2019-05-29T21:29:59.983Z", "grpc.service": "orderer.AtomicBroadcast", "grpc.method": "Broadcast", "grpc.peer_address": "172.18.0.6:35118", "error": "rpc error: code = Canceled desc = context canceled", "grpc.code": "Canceled", "grpc.call_duration": "323.004µs"}
2019-05-29 21:30:44.584 UTC [comm.grpc.server] 1 -> INFO 009 streaming call completed {"grpc.start_time": "2019-05-29T21:30:44.582Z", "grpc.service": "orderer.AtomicBroadcast", "grpc.method": "Broadcast", "grpc.peer_address": "172.18.0.6:35124", "grpc.code": "OK", "grpc.call_duration": "1.984117ms"}
Hi @Hanesoliveira, always happy to help!
I just look at the lab guide, and noticed the following line:
"Try it Yourself: Let’s do it once more on peer1. Set the environment variables for peer1.Org1 to the appropriate values."
^ It looks like a misprint, and we will be removing it tomorrow morning.
If this is where you or anyone else are getting your error, please move on. You have done nothing wrong. Just be sure that you've instantiated the chaincode successfully once on the same channe, andl then you're fine to move on.
As mentioned in the Lectures, Chaincode Instantiation is at channel level, which in simplest terms means it only needs to be instantiated once.
Hope this helps!
Hi,
I got the following error while trying to instantiate the contract with or without endorsing policy.
Any idea as to why both commands are faling?
1st Command:
peer chaincode instantiate -n ccForAll -v 1.0 \ -o orderer.example.com:7050 -C allarewelcome \ -c '{"Args":["Mach","50"]}' \ --policy "AND('Org1.peer', OR ('Org1.member))"
Result:
Error: error getting channel (allarewelcome) orderer endpoint: error bad proposal response 500: access denied for [GetConfigBlock][allarewelcome]: Failed to get policy manager for channel [allarewelcome]
2nd Command:
peer chaincode instantiate -n ccForAll -v 1.0 -o orderer.example.com:7050 -C allarewelcome -c '{"Args":["Mach","50"]}'
Result:
Error: error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [allarewelcome] creator org [Org1MSP]
Any idea on how to resolve this?
Hi @PaulAmehUgw1!
Remove the "\" from your command, this is used for continuing the command in another line.
Hi @PaulAmehUgw1!
How are you setting your environment variables? Can you post here?
Environment variables when installing chaincode for Peer0.0rg1:
docker exec -it cli bash
export CORE_PEER_LOCALMSPID=Org1MSP
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/ peer/crypto/peerOrganizations/org1.example.com/users/[email protected] e.com/msp
I followed this instruction “Using the above walkthrough, try and install chaincode on peer1.org”
For Peer1.0rg1:” To install on peer1.Org1 with the following command.
docker exec -it cli bash
export CORE_PEER_LOCALMSPID=Org1MSP
export CORE_PEER_ADDRESS=peer1.org1.example.com:7051
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/ peer/crypto/peerOrganizations/org1.example.com/users/[email protected] e.com/msp
@PaulAmehUgw1 It looks like your pathing for CORE_PEER_MSPCONFIGPATH is broken toward the end. Please double check it for breaks. The value should be one solid command.
Please fix that and then rerun the command
For all wondering, the above issue is most likely due to the translation from PDF to Command Line. Please be conscious of the default page breaks and other formatting that gets added in documents.
@kmyatt I successfully installed the chaincode and after that the instantiation is not going through. Both commands returns error message.
1)
peer chaincode instantiate -n ccForAll -v 1.0 -o orderer.example.com:7050 -C allarewelcome -c '{"Args":["Mach","50"]}'
Output:
2019-06-18 13:51:19.934 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2019-06-18 13:51:19.934 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
Error: error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [allarewelcome] creator org [Org1MSP]
2)
peer chaincode instantiate -n ccForAll -v 1.0 -o orderer.example.com:7050 -C allarewelcome -c '{"Args":["Mach","50"]}' --policy "AND('Org1.peer', OR ('Org1.member'))"
Output:
Error: error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [allarewelcome] creator org [Org1MSP]
Blockchain logs returns:
orderer.example.com | 2019-06-18 13:54:13.163 UTC [comm.grpc.server] 1 -> INFO 015 streaming call completed {"grpc.start_time": "2019-06-18T13:54:13.163Z", "grpc.service": "orderer.AtomicBroadcast", "grpc.method": "Broadcast", "grpc.peer_address": "172.18.0.4:41454", "grpc.code": "OK", "grpc.call_duration": "242.251µs"}
3)
peer chaincode list --instantiated -C allarewelcome
Output:
peer0.org1.example.com | 2019-06-18 14:00:13.899 UTC [comm.grpc.server] 1 -> INFO 032 unary call completed {"grpc.start_time": "2019-06-18T14:00:13.899Z", "grpc.service": "protos.Endorser", "grpc.method": "ProcessProposal", "grpc.peer_address": "172.18.0.4:58666", "error": "access denied: channel [allarewelcome] creator org [Org1MSP]", "grpc.code": "Unknown", "grpc.call_duration": "296.481µs"}
Based on the above output the instantiation failed. Any idea on how I can fix these error?
Hi @PaulAmehUgw1!
Can you see if you're still enrolled in the channel?
@hanesoliveira I checked:
peer channel fetch oldest allarewelcome.block -c allarewelcome --orderer orderer.example.com:7050
Response from both peers:
2019-06-18 16:08:36.387 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-06-18 16:08:36.388 UTC [cli.common] readBlock -> INFO 002 Received block: 0
@PaulAmehUgw1 what shows up when you execute the command "peer channel list"?
@hanesoliveira
Response:
Endorser and orderer connections initialized
Channels peers has joined:
Ok @PaulAmehUgw1. That shows that you are not in the channel and you need to join the channel:
peer channel join -b allarewelcome.block
Thanks @hanesoliveira I was to join back the channels.The reason both peers keeps getting off the channel is due to restarting the containers. However, I get this error when instantiating the smart contract. It hangs then pops this.
2019-06-18 16:56:02.319 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2019-06-18 16:56:02.319 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: API error (404): network startFiles_basic not found
Hi @PaulAmehUgw1, try to see if this network is available issuing:
docker network list
Sometimes I got problems after containers stopped or got restarted. Check also if your containers have the right config of networking on docker-composer.yaml.
@hanesoliveira Thanks!
I just edited the name "CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE = startFiles_basics" to startfiles_basic, it worked. Typo problem.
Great @PaulAmehUgw1!
*Revised comment for explanation to everyone
Hey everyone just to be clear., if you receive the error:
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: API error (404): network startFiles_basic not found
Head into your docker-compose file and replace the line:
wtih this line.
Explanation: The old method used to work, but as of 1.4 the error occurs much more often. We will be removing this with the next update
Alternatively You do have the option to override the value inside of the container, which may work as well.
Hi @kmyatt ,
I did change the docker-compose file, but the container still reports same error (startFiles_basic not found). Do one have to restart the whole network when changing the docker-compose file? If so, do you always have to type inn all commands manually again? Like for instance creating the genesis block and joining channels and installing chaincode?
Its not "startFiles_basic ", change the caps F to small f "startfiles_basic ".
Hi @indirajith yes I changed it to startfiles_basic, but the error message "startFiles_basic not found" still show up, thats why I wondered if I need to restart the network after editing the docker-compose file?
`docker network prune -f' this deletes all the docker networks. Try this. And make sure for both peers the network name is correct.
Yes, @Niklaskkkk you can also simply run the ./teardown.sh script from the startFiles folder directly. This will cover the container teardown as well as the network removal.