questions about Hyperledger composer-rest-server - hyperledger-composer

Bus error occurs when I run composer-rest-server, why?Thanks
zcy#ubuntu:~$ composer-rest-server -c admin#foodsupplychain -n always
Discovering types from business network definition ...
Bus error

You can run stopFabric.sh and teardownFabric.sh and also delete all the network card and retry. I think it should work for you.

Related

Hyperledger Composer Ping gives REQUEST_TIMEOUT

I am working on composer v0.16. I am trying to add 2 new nodes to an existing 2 node blockchain network. Everything works fine on the first 2 nodes. On the new nodes, when I try to ping the network with the peer Admin card or try to interact with the network using the card, the operation waits for a long time and then gives a "Error: Error trying invoke business network. Error: Error: REQUEST_TIMEOUT" error.
I have checked the composer version is same on all 4 nodes. The state of the identity is "Bound" not "Active". Anything else that can be done to check version mismatch. What else can be checked?
It was trying to find the Orderer using the Orderer alias name in the connection.json and failing. Hence the timeout. Replacing the Orderer alias with the actual hostname resolved the issue.

“Error: could not find chaincode” occurs when execute composer runtime install

We're thinking about migration from Hyperledger Composer v0.13.0 to the latest one (v0.16.5), so I have tried to create and deploy business network according tutorial below.
https://hyperledger.github.io/composer/latest/tutorials/developer-tutorial
But at the Step 4, composer runtime install command doesn't work.
Here is the error occured.
✖ Installing runtime for business network <<MY_BUSINESS_NETWORK>>. This may take a minute...
Error: Error trying to ping. Error: Error trying to query business network. Error: could not find chaincode with name '<<MY_BUSINESS_NETWORK>>' - make sure the chaincode <<MY_BUSINESS_NETWORK>> has been successfully instantiated and try again
Command failed
But I'm not sure where instantiation should be done.
I guess that composer runtime install and composer network start are counterparts of composer network deploy in v0.13.0, but is it wrong? In v0.13.0, I didn't need to execute "instantiate" command explicitly.
I would appreciate any suggestions or information, thanks.
My procedure
1. prepare credentials,channenl-artifacts and connection profile then start dockers.
2. create channel and make peers joined.
3. create BNA & card Files.
4. import the card of PeerAdmin then confirm with composer card list command.
5. execute composer install runtime command.
Environment
Ubuntu : 16.04
hyperledger composer : 0.16.5
ibmblockchain/fabric-tools 1.0.5
ibmblockchain/fabric-ca 1.0.5
ibmblockchain/fabric-peer 1.0.5
ibmblockchain/fabric-orderer 1.0.5
ibmblockchain/fabric-couchdb 1.0.5
the runtime install and network start (as you correctly understood) are two separate tasks that are likely to be performed by a Peer administrator and a network administrator (two separate roles) and hence why they are broken out - demarcation of duty. network deploy is deprecated from old days.
On tutorial - I suggest to do a 'teardown' from the fabric-tools directory and clear out your $HOME/.composer cards directory. I assume you downloaded a new fabric tools afresh? Did you also make sure to update your pre-requisites if/as required per the documentation https://hyperledger.github.io/composer/latest/installing/installing-prereqs.html
The error you posted related to << MY_BUSINESS NETWORK >> I assume, is because you've obfuscated the real network name - understandable) otherwise is an unusual error and not the name given in the tutorial - if you follow the tutorial it should deployed as follows (ie cut and paste from tutorial):
runtime install:
composer runtime install --card PeerAdmin#hlfv1 --businessNetworkName tutorial-network
network start:
composer network start --card PeerAdmin#hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile tutorial-network#0.0.1.bna --file networkadmin.card
https://hyperledger.github.io/composer/latest/tutorials/developer-tutorial.html and this has been working fine for ages.
Are you trying to build your own Fabric network, single-org or multi-org, on same virtual host or across different physical/virtual machines ? Because the Fabric Dev server setup provided by Composer does 1 and 2 for you. You can also create the PeerAdmin card for that, as instructed in our docs (run a script).
Based on your procedure I would add first:
Do a teardown and remove old cards (as mentioned above)
do your steps 1 and 2 (and then create your Fabric network if that's what you want to do)
After your [custom] Fabric is up and running:
step 3. Test your custom Fabric Network to validate the configuration using the Fabric marbles sample chaincode. If that works, proceed to build your own PeerAdmin card
step 4. deploy the Business network by installing Composer runtime on all peers first then doing a network start of the bna on the channel you configured
step 5. Create Composer BN cards, connection profiles, identities and participants etc

Authorization failure when creating new business network in local playground

I am trying follow the steps of Composer Playground tutorial for local version of the playground and using local fabric peer.
I have done prescribed sequence of steps: downloadFabric.sh, startFabric.sh, createPeerAdminCard.sh. Once I bring up the playground, I can see network card PeerAdmin#hlfv1 showing no business network attached to it.
Then I click on Deploy a New Business Network, and select "vehicles-lifecycle-network" example. The dialog looks similar to the one in tutorial, but it has additional fields asking for credentials for network administrator, and I am not sure what to put there.
I tried copying in key and certificate that were generated by createPeerAdminCard script, and I also tried using ID and Secret option putting in PeerAdmin or PeerAdmin#hlfv1. I found this answer which indicates that it does not matter what secret you specify as the user is already imported into the keystore -- not sure if it is relevant. It certainly did not make any difference.
When I click deploy, the new network seems to appear in the composer dashboard. However, if I click on "Connect Now", a popup shows "Error trying to login and get user context" and [[{"code":400,"message":"Authorization Failure"}]].
It seems I am missing something very basic, but cannot really figure it out on my own.
Edit:
Simple steps to reproduce (assuming basic-sample-network.bna is available locally):
> composer runtime install -c PeerAdmin#hlfv1 -n basic-sample-network
> composer network start -a <path to basic-sample-network.bna> -A admin -c PeerAdmin#hlfv1 -C <path to PeerAdmin certificate> -f admin.card
> composer card import -f admin.card
> composer network ping -c admin#basic-sample-network
Last command produces the same error as above in the console.
Edit 2:
If I open up ~/.composer/cards/PeerAdmin#hlfv1/metadata.json and add "businessNetwork":"basic-sample-network" parameter, I am able to do composer network ping -c PeerAdmin#hlfv1 successfully, and also can connect to the network from the Playground -- this will do as a workaround for now. However, I must be doing something wrong with the way I create new network and its admin card.
The Playground Tutorial assumes that you are connecting to an Online Hosted Playground hosted on IBM Cloud (Bluemix). For the Online Playground the underlying Fabric is 'Web' - i.e. the Fabric is stored only in the local browser. This document may help explain the different Fabric Runtimes: Typical Solution Architecture
The Local Playground gives you the additional option of deploying a Business Network to an hlfv1 Fabric, using the PeerAdmin card that you created with the createPeerAdmin.sh script.
After creating the PeerAdmin card you should be able to start Playground locally with the composer-playground command and you should be able to deploy a Business Network. In this development scenario the Credentials for the Network Administrator should be Id and Secret specifying admin / adminpw. There is no need to run CLI commands prior to starting local playground. (createPeerAdminCard.sh is not a CLI command but is a Dev environment setup script - and it should be run.)
If you want to go down the CLI route please see the Developer Tutorial

Composer-Rest-Server not connecting

I am testing a a business network I created, I ran the Composer-rest-server and all worked fine, then shut the server as suggested in the developers guide , then I proceeded use the yo hyperledger composer to create the skeleton of the angular app, however, now the angular app is showing in the local browser, however, the composer-rest- server is not.
Expected Behavior:
I should start the composer-rest- server in localhost:3000 and the angular app as well
Actual Behavior:
I get this message;
scovering types from business network definition ...
Connection fails: Error: Error trying to ping. Error: Error trying to query chaincode. Error: Connect Failed
It will be retried for the next request.
Exception: Error: Error trying to ping. Error: Error trying to query chaincode. Error: Connect Failed
Error: Error trying to ping. Error: Error trying to query chaincode. Error: Connect Failed
at _checkRuntimeVersions.then.catch (/home/node/.nvm/versions/node/v6.11.2/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:696:34)
Your Environment
composer-cli#0.11.3
generator-hyperledger-composer#0.11.3
composer-rest-server#0.11.3
Docker version 17.06.0-ce, build 02c1d87
docker-compose version 1.13.0, build 1719ceb
The Problem
If you kill your fabric instance using ./stopFabric that you started using the ./startFabric command then all the containers that were apart of the business network were killed as well and therefore you need to reinstall the .bna and start the network again. (the development flow provided is purposely volatile for rapid development)
The Solution
1.) Type docker ps to see all of your running containers. You should see none if you are getting that error because your peer is not responding to pings
2.) Open a separate terminal and navigate to where you have fabric-dev-servers in the terminal and run ./fabricStart. This will start all the containers like your network Certificate Authority, the peer, the orderer, etc.
3.) Return to your project in another terminal. Do Step 1 & 2 found at the developer tutorial (you likely won't need to do step 3 since you likely already imported the network administrator identity going through the tutorial)
4.) Run composer network ping --card admin#tutorial-network. The ping should go through.
5.) Run docker ps. You should see 4 containers running
6.) Run composer-rest-server and follow the steps from the tutorial.
7.) Run cd tutorial-network-app to switch to where your angular application is (or wherever you generated it with the yo command)
8.) Navigate to http://localhost:3000 and everything should work.
Any other questions or problems just reply here and I can help.
The expected behaviour is that the REST server is already running (the the generator uses Loopback to spin up a REST server already (that's why you shut down the previous REST server)). Its described here https://hyperledger.github.io/composer/unstable/tutorials/developer-guide.html under 'Generate your Skeleton Web Application'.
After you created the application - following completion of the yo hyperledger-composer questions (and after providing the answers) you run your application using npm start from within the generated application directory. Your app is accessible at http://localhost:4200.

Unable to deploy business network after upgrading to composer v0.8.0

I have a business network which has deployed no problem in the past, now when I try to deploy using the command
composer network deploy -a test.bna -i PeerAdmin -s adminpw -p hlfv1
I get
Deploying business network from archive: test.bna
Business network definition:
Identifier: test#0.0.1
Description: Test Network
✖ Deploying business network definition. This may take a minute...
Error: error trying deploy. Error: Failed to deserialize creator
identity, err MSP Org1MSP is unknown
Command failed
what is the problem ?
This error could be the result of a problem to create the channel and join the peer to the channel.
If you followed the hyperledger composer guides and downloaded the hyperledger fabric development server then you must ensure you have a version of docker equal or greater to version 17.03. The channel will fail to be created on older versions of docker.
It seems also a problem related to the connection profile and the new changes on identities. Check https://hyperledger.github.io/composer/business-network/bnd-deploy.html and Trying to deploy a business network onto hyperledger fabric 1.0 beta fails to install chaincode

Resources