Unable to Register Chaincode & Successfully Start Blockchain Network - docker

I am following hyperledger fabric tutorial, and am having trouble registering my chaincode and possibly starting the docker image:
https://www.ibm.com/developerworks/library/j-chaincode-for-java-developers/
The following is the error I am getting when I try to register my chaincode:
$ ./Example
Hello world! starting [Ljava.lang.String;#5fd0d5ae
May 10, 2017 9:40:34 PM example.Example main
INFO: starting
May 10, 2017 9:40:34 PM io.grpc.internal.TransportSet$1 call
INFO: Created transport io.grpc.netty.NettyClientTransport#7269e694(/127.0.0.1:7051) for /127.0.0.1:7051
May 10, 2017 9:40:36 PM io.grpc.internal.TransportSet$TransportListener transportShutdown
INFO: Transport io.grpc.netty.NettyClientTransport#7269e694(/127.0.0.1:7051) for /127.0.0.1:7051 is being shutdown
May 10, 2017 9:40:36 PM io.grpc.internal.TransportSet$TransportListener transportTerminated
INFO: Transport io.grpc.netty.NettyClientTransport#7269e694(/127.0.0.1:7051) for /127.0.0.1:7051 is terminated
May 10, 2017 9:40:36 PM org.hyperledger.java.shim.ChaincodeBase$1 onError
SEVERE: Unable to connect to peer server: UNAVAILABLE
My blockchain network via docker is up and running, but the last log message is different than the expected log message (It says Connected to: [], which I assume is a null):
05:47:30.205 [peer] chatWithSomePeers -> DEBU 02f Starting up the first peer of a new network
05:47:30.205 [nodeCmd] serve -> INFO 030 Starting peer with ID=name:"vp0" , network ID=dev, address=172.17.0.3:7051, rootnodes=, validator=true
05:47:30.206 [consensus/statetransfer] verifyAndRecoverBlockchain -> DEBU 031 Validating existing blockchain, highest validated block is 0, valid through 0
05:47:30.206 [consensus/statetransfer] blockThread -> INFO 032 Validated blockchain to the genesis block
05:47:30.206 [consensus/handler] 1 -> DEBU 033 Starting up message thread for consenter
05:47:30.207 [peer] ensureConnected -> DEBU 034 Starting Peer reconnect service (touch service), with period = 6s
05:47:30.207 [rest] StartOpenchainRESTServer -> INFO 035 Initializing the REST service on 0.0.0.0:7050, TLS is disabled.
05:47:36.209 [peer] ensureConnected -> DEBU 036 Touch service indicates no dropped connections
05:47:36.209 [peer] ensureConnected -> DEBU 037 Connected to: []
05:47:36.209 [peer] ensureConnected -> DEBU 038 Discovery knows about: []
When I check for containers that are running docker shows me both of them are up, see below:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7dec77752d52 hyperledger/fabric-peer "sh -c 'sleep 5; peer" 20 minutes ago Up 20 minutes 0.0.0.0:7050-7051->7050-7051/tcp, 0.0.0.0:7053->7053/tcp blockchain_vp0_1
ac91e9bc1b0e hyperledger/fabric-membersrvc "membersrvc" 24 hours ago Up 20 minutes 0.0.0.0:7054->7054/tcp blockchain_membersrvc_1
The following git command was used:
git clone https://github.com/hyperledger/fabric.git -b v0.6
I copied and pasted the exact values for the docker-compose.yml, see below:
membersrvc:
image: hyperledger/fabric-membersrvc
ports:
- "7054:7054"
command: membersrvc
vp0:
image: hyperledger/fabric-peer
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp0
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=false
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
links:
- membersrvc
command: sh -c "sleep 5; peer node start --peer-chaincodedev"
Is there something I am missing here? Any help is appreciated, thank you.

Seems you are working on Windows environment and did everything right except not defined any port forwarding into Oracle VM virtual box. you will have to configure
Oracle VM VirtualBox Manager - > Setting - > Network -> Advance - > port forwarding -- and define as per attached image, run and enjoy.... enter image description here
Happy Coding!

Related

peer node unable to create chaincode container - dial unix /host/var/run/docker.sock: connect: permission denied error

I am trying to setup hyperledger network on centos
Using 1.1.0 images from ibmblockchain docker hub.
I am able to start up the network without any issues. that is 1 orderer, 3 kafkas, 3 zookeepers and 2 peers.
But every time i try to instantiate chaincode, I see the below error in the peer docker containers. Can anyone help me with this issue.
2018-07-19 19:05:30.570 UTC [dockercontroller] Start -> ERRO 3ac start-could not recreate container , because of Post http://unix.sock/containers/create?name=dev-peer1.bns-250A-v1.0.2-b3: dial unix /host/var/run/docker.sock: connect: permission denied
2018-07-19 19:05:30.570 UTC [container] unlockContainer -> DEBU 3ad container lock deleted(dev-peer1.bns-250A-v1.0.2-b3)
2018-07-19 19:05:30.570 UTC [chaincode] launchAndWaitForRegister -> DEBU 3ae stopping due to error while launching: Post http://unix.sock/containers/create?name=dev-peer1-chaincode1-v1.0.2-b3: dial unix /host/var/run/docker.sock: connect: permission denied
error starting container.
Thank you.
The problem is a permission issue with /var/run/docker.sock.
Check your /var/run/docker.sock permission.
ls -l /var/run/docker.sock will let u know if you have the correct .permission
sudo chmod 666 /var/run/docker.sock should give it correct rw access.
I was able to fix this by adding Username, UserID and GroupID permissions to the docker run command.
Ex:
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: ibmblockchain/fabric-peer-$ARCH:1.1.0
environment:
- CORE_LOGGING_LEVEL=debug
- CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=composer_default
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peer/msp
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- USERNAME=(your userid)
- USER_ID=1000
- GROUP_ID=999
This is mentioned as the solution in ibmblockchain github repo :
https://github.com/IBM-Blockchain/ibm-blockchain-issues/issues/125

How to add advanced Kafka configurations to the Landoop `fast-data-dev` image

Does anyone know how to pass custom Kafka configuration options to the landoop/fast-data-dev docker image?
Since there is no way to puss a custom config file and/or config params, what I've tried so far was to mount my own server.properties config file into /opt/confluent/etc/kafka by adding the following into my docker compose file
landoop:
hostname: 'landoop'
image: 'landoop/fast-data-dev:latest'
expose:
- '3030'
ports:
- '3030:3030'
environment:
- RUNTESTS=0
- RUN_AS_ROOT=1
volumes:
- ./docker/landoop/tmp:/tmp
- ./docker/landoop/opt/confluent/etc/kafka:/opt/confluent/etc/kafka
however, this causes Kafka to throw the following logs:
landoop_1 | 2017-09-28 11:53:03,886 INFO exited: broker (exit status 1; not expected)
landoop_1 | 2017-09-28 11:53:04,749 INFO spawned: 'broker' with pid 281
landoop_1 | 2017-09-28 11:53:05,851 INFO success: broker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
landoop_1 | 2017-09-28 11:53:11,867 INFO exited: rest-proxy (exit status 1; not expected)
landoop_1 | 2017-09-28 11:53:12,604 INFO spawned: 'rest-proxy' with pid 314
landoop_1 | 2017-09-28 11:53:13,024 INFO exited: schema-registry (exit status 1; not expected)
landoop_1 | 2017-09-28 11:53:13,735 INFO spawned: 'schema-registry' with pid 341
landoop_1 | 2017-09-28 11:53:13,739 INFO success: rest-proxy entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
in addition, when I go to http://localhost:3030/kafka-topics-ui/, I see the following:
KAFKA REST
/api/kafka-rest-proxy
CONNECTIVITY ERROR
Any suggestions? Thank you.
There are couple of things that i did which simplified the whole process. This is valid only for dev environment
Start the docker with a interactive shell as the entry point
Start the docker on the host network
Make necessary changes to the server.properties file include the host IP where the docker was running (as mentioned in (2) docker is running on host network)
** 4. If you want to make any advanced configuration, you may do now**
Run the actual entry point "/usr/local/bin/setup-and-run.sh"
Actual commands used:
Start the container
sudo docker run -it --entrypoint /bin/bash --net=host --rm -e ADV_HOST=HOSTIP landoop/fast-data-dev:latest
Add following to /run/broker/server.properties
advertised.host.name = HOST-IP
advertised.port = 9092
Run /usr/local/bin/setup-and-run.sh
At today, with latest version of landoop/fast-data-dev is possible to specify custom Kafka configuration options by converting the configuration option to uppercase, replacing dots with underscores and prepending with KAFKA_.
For example if you want to set specific values for "log.retention.bytes" and "log.retention.hours" you should add the following to your docker compose environment section:
environment:
KAFKA_LOG_RETENTION_BYTES: 1073741824
KAFKA_LOG_RETENTION_HOURS: 48
ADV_HOST: 127.0.0.1
RUNTESTS: 0
BROWSECONFIGS: 1
You can specify this way also configuration options for other services ( schema registry, connect, rest proxy ). Check doc for details https://hub.docker.com/r/landoop/fast-data-dev/.
Once the container is up you can confirm this by looking at configuration file at the following path inside the container:
/run/broker/server.properties
or also through the Landoop UI at the following URL if you've set "BROWSECONFIGS" to 1 on the environments parameters:
http://127.0.0.1:3030/config/broker/server.properties

Transaction not found on remote peer

I'm trying to setup simple blockchain network with Hyperledger fabric v1.0 on 2 instances.
My scenario
Instance A: Orderer and Peer0
Instance B: Peer1
I basically followed the "Use the native binaries" section of "Getting Started" page.
What I tried is I started 1 orderer and 1 peer on instanceA.
I installed, instantiated, invoked and made a query the example chaincode.
Then I started 1 peer on instanceB.
I could let peer1 on instanceB join my channel from instanceA. I could install the chaincode on peer1 from instanceA.
But I could not execute query peer1 from instanceA.
I can see at least chaincode installed on instanceB.
Error message is:
Error: Error endorsing query: rpc error: code = 2 desc = failed to obtain cds for mycc - transaction not found mycc/mychannel1
Below are commands I tried...
[InstanceA terminal1] 1. generate orderer.block
$ configtxgen -profile SampleSingleMSPSolo -outputBlock orderer.block
[InstanceA terminal2] 2. start orderer
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_LOGGING_LEVEL=DEBUG ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 ORDERER_GENERAL_GENESISMETHOD=file ORDERER_GENERAL_GENESISFILE=./orderer.block
2017-04-08 23:38:41.562 UTC [orderer/multichain] NewManagerImpl -> INFO 001 Starting with system channel testchainid and orderer type solo
2017-04-08 23:38:41.562 UTC [orderer/main] NewServer -> INFO 002 Starting orderer
2017-04-08 23:38:41.562 UTC [orderer/main] main -> INFO 003 Beginning to serve requests
2017-04-08 23:39:39.881 UTC [orderer/multichain] newChain -> INFO 004 Created and starting new chain mychannel1
[InstanceA terminal1] 3. generate channel.tx
$ configtxgen -profile SampleSingleMSPSolo -outputCreateChannelTx channel.tx -channelID mychannel1
[InstanceA terminal3] 4. start peer0
$ CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7051 CORE_LOGGING_LEVEL=DEBUG CORE_PEER_LOCALMSPID=DEFAULT peer node start --peer-defaultchain=false
[InstanceA terminal1] 5. Create Channel
$ CORE_PEER_LOCALMSPID=DEFAULT peer channel create -o 127.0.0.1:7050 -c mychannel1 -f channel.tx
[InstanceA terminal1] 6. Join peer0 to mychannel1
$ CORE_PEER_LOCALMSPID=DEFAULT peer channel join -b mychannel1.block
Peer joined the channel!
2017-04-08 23:39:54.463 UTC [main] main -> INFO 001 Exiting.....
[InstanceA terminal1] 7. Install a chaincode
$ CORE_PEER_LOCALMSPID=DEFAULT peer chaincode install -o 127.0.0.1:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
ncode/go/chaincode_example02
2017-04-08 23:40:05.744 UTC [golang-platform] writeGopathSrc -> INFO 001 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:40:05.744 UTC [container] WriteFolderToTarPackage -> INFO 002 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:40:36.242 UTC [main] main -> INFO 003 Exiting.....
[InstanceA terminal1] 7. Instantiate the chaincode
$ CORE_PEER_ADDRESS=127.0.0.1:7051 CORE_PEER_LOCALMSPID=DEFAULT peer chaincode instantiate -o 127.0.0.1:7050 -C mychannel1 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}'
1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}'
2017-04-08 23:40:39.892 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2017-04-08 23:40:39.893 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2017-04-08 23:40:42.194 UTC [main] main -> INFO 003 Exiting.....
[InstanceA terminal1] 8. Invoke and query a command
$ CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode invoke -o 127.0.0.1:7050 -C mychannel1 -n mycc -c '{"Args":["invoke","a","b","10"]}'
$ CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode query -o 127.0.0.1:7050 -C mychannel1 -n mycc -c '{"Args":["query","a"]}'
Query Result: 90
2017-04-08 23:40:51.664 UTC [main] main -> INFO 001 Exiting.....
[InstanceB terminal1] 9. Create peer1 on instanceB
$ CORE_PEER_MSPCONFIGPATH=/home/kouohhashi/work/src/github.com/hyperledger/fabric/msp/sampleconfig CORE_PEER_GOSSIP_EXTERNALENDPOINT=instanceB:7051 CORE_LOGGING_LEVEL=DEBUG CORE_PEER_LOCALMSPID=DEFAULT peer node start --peer-defaultchain=false
[InstanceA terminal1] 10. Join peer1 on instance B to mychannel1 from instanceA
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_PEER_ADDRESS=instanceB:7051 peer channel join -b mychannel1.block
Peer joined the channel!
2017-04-08 23:42:14.799 UTC [main] main -> INFO 001 Exiting.....
[InstanceA terminal1] 11. Install chaincode on peer1 on instanceB from instance A
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_PEER_ADDRESS=instanceB:7051 peer chaincode install -o 127.0.0.1:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2017-04-08 23:42:23.166 UTC [golang-platform] writeGopathSrc -> INFO 001 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:42:23.166 UTC [container] WriteFolderToTarPackage -> INFO 002 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:42:39.191 UTC [main] main -> INFO 003 Exiting.....
[InstanceA terminal1] 12. Query peer1 from instanceA
$ CORE_PEER_ADDRESS=instanceB:7051 peer chaincode query -o 127.0.0.1:7050 -C mychannel1 -n mycc -c '{"Args":["query","a"]}'
I got errors like below. But I can see at least mycc chaincode on
instnceB and peer join command was completed successfully.
Error: Error endorsing query: rpc error: code = 2 desc = failed to obtain cds for mycc - transaction not found mycc/mychannel1
I'm using 2 ubuntu16.04 instances and not using docker or vagrant at all. I compiled binaries by make native.
Peer1 on instanceB may not connect orderer on instanceA because I saw the error log on peer1.
2017-04-08 23:42:14.903 UTC [deliveryClient] NewDeliverService -> ERRO 286 Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing
Looks like peer1 tried to connect 0.0.0.0 instead of instanceA.
By the way I changed the Name of Organizations to DEFAULT from SampleOrg because I got errors like below otherwise.
2017-04-08 05:17:57.919 UTC [gossip/service] configUpdated -> ERRO 25e Tried joining channel mychannel1 but our org( DEFAULT ), isn't among the orgs of the channel: [SampleOrg] , aborting.
I think this may be because peer1 on instanceB was not linked to orderder on instanceA or transaction made by peer0 was not completed and reflected on instanceB. But I have no idea how to dig in...
Please give me help.
Thanks.
I finally solved my problem.
I turned out to be simple.
The solution was changing addresses of the orderer from 127.0.0.1:7050 to (IP Address of InstanceA):7050
common/configtx/tool/configtx.yaml
Orderer: &OrdererDefaults
# Orderer Type: The orderer implementation to start.
# Available types are "solo" and "kafka".
OrdererType: solo
Addresses:
# - 127.0.0.1:7050
- <IP Address of InstanceA>:7050
By doing this, Peer1 on instanceB start connecting orderer on instanceA.
It looks like "CORE_PEER_COMMITTER_LEDGER_ORDERER environmental parameter" and "-o option" were not used anymore or overwritten by configtx.yaml.

ERRO : Error trying to connect to local peer: grpc: timed out trying to connect

Unable to deploy chaincode example in my local hyperledger fabric.
system config: mac osx, Docker toolbox for mac
One validating peer is up and running using docker-compose.yaml
membersrvc:
image: hyperledger/fabric-membersrvc
command: membersrvc
vp0:
image: hyperledger/fabric-peer
environment:
- CORE_PEER_ADDRESSAUTODETECT=false
- CORE_VM_ENDPOINT=http://172.17.0.1:2375
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
links:
- membersrvc
command: sh -c "sleep 5; peer node start --peer-chaincodedev"
While deploying chaincode by running
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./test
Its showing the error as [shim] ERRO : Error trying to connect to local peer: grpc: timed out trying to connect
I tried replacing CORE_PEER_ADDRESS as suggested by grep timeout solution but no change in error.
First Validating peer output
Chaincode deployment error window
You need to use the correct port number on which peer process is listening to.
instead of using the following command,
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./test
try this instead,
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7052 ./test
if it doesn't work then run the following command to check your listening port and use that instead,
netstat -atp tcp | grep -i "listen"

Setting Up a Network For Development in Hyperledger Fabric v0.5-preview

My demo project is running OK already, but it is only one peer in network. I want to add more peers into network.
I followed this guide ==> https://github.com/hyperledger-archives/fabric/blob/540c4db5f64dba4bd1b18e896c96a8d17d7ec552/docs/dev-setup/devnet-setup.md.
Please kindly help to check the log below,
the directory was wrong? or what is the right way to run this start up of peer?
vagrant#hyperledger-devenv:v-:/opt/gopath/src/github.com/hyperledger/fabric$ docker run --rm -it -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true hyperledger-peer peer node start
Unable to find image 'hyperledger-peer:latest' locally
Pulling repository docker.io/library/hyperledger-peer
docker: Error: image library/hyperledger-peer not found.
See 'docker run --help'.
Is it possible that first node in network was started not in Docker container? (For example it could be started as a process using peer node start)
We can verify which docker images are available in vagrant machine. Just run docker images command:
vagrant#hyperledger-devenv:v0.0.9-b4acc4b:$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-baseimage latest c1d6f4800a55 27 hours ago 1.297 GB
hyperledger/fabric-baseimage x86_64-0.0.9 70328eed56aa 2 weeks ago 990.1 MB
busybox latest 47bcc53f74dc 9 weeks ago 1.113 MB
With such configuration, when “hyperledger-peer” image is not available, the Validation Peer will not be started because of “Unable to find image” error:
vagrant#hyperledger-devenv:v0.0.9-b4acc4b:/opt/gopath/src/github.com/hyperledger/fabric/peer$ docker run --rm -it -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true hyperledger-peer peer node start
Unable to find image 'hyperledger-peer:latest' locally
Pulling repository docker.io/library/hyperledger-peer
docker: Error: image library/hyperledger-peer not found.
"hyperledger-peer:latest" image can be created using:
cd $GOPATH/src/github.com/hyperledger/fabric/core/container
go test -run BuildImage_Peer
Now docker images should show one more available image:
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger-peer latest 438b65f18f21 8 seconds ago 1.418 GB
at this point Validation Peer should be started successfully:
vagrant#hyperledger-devenv:v0.0.9-b4acc4b:~$ docker run —rm -it -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true hyperledger-peer peer node start
21:55:51.969 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO
21:55:51.970 [peer] func1 -> INFO 002 Auto detected peer address: 172.17.0.2:30303
21:55:51.971 [peer] func1 -> INFO 003 Auto detected peer address: 172.17.0.2:30303
21:55:51.972 [peer] func1 -> INFO 004 Auto detected peer address: 172.17.0.2:30303
21:55:51.974 [main] serve -> INFO 005 Security enabled status: false
21:55:51.974 [main] serve -> INFO 006 Privacy enabled status: false
…

Resources