Working with Hyperledger Composer V0.12 invoking the deploy function using the following code, which returns a 'successful' result:
/**
* Deploys a new BusinessNetworkDefinition to the Hyperledger Fabric. The connection must be connected for this method to succeed.
* #param {express.req} req - the inbound request object from the client
* req.body.myArchive: _string - string name of object
* req.body.deployOptions: _object - string name of object
* #param {express.res} res - the outbound response object for communicating back to client
* #param {express.next} next - an express service to enable post processing prior to responding to the client
* returns composerAdmin.connection - either an error or a connection object
* #function
*/
exports.deploy = function(req, res, next) {
let newFile = path.join(path.dirname(require.main.filename),'network/dist',req.body.myArchive);
let archiveFile = fs.readFileSync(newFile);
let adminConnection = new composerAdmin.AdminConnection();
return BusinessNetworkDefinition.fromArchive(archiveFile)
.then(function(archive) {
adminConnection.connect(config.composer.connectionProfile, config.composer.adminID, config.composer.adminPW)
.then(function(){
adminConnection.deploy(archive)
.then(function(){
console.log('business network '+req.body.myArchive+' deployed successful: ');
res.send({deploy: req.body.myArchive+' deploy succeeded'});
})
.catch(function(error){
console.log('business network '+req.body.myArchive+' deploy failed: ',error);
res.send({deploy: error});
});
});
});
};
However when I go through the following process:
start docker images, deploy network using cli
ping
undeploy
ping
deploy
ping
I get the following results:
[2] at: 08:10:36.058 Url is: /composer/admin/ping
network ping successful: { version: '0.12.0', participant: null }
[3] at: 08:11:05.503 Url is: /composer/admin/undeploy
zerotoblockchain-network network undeploy successful
[4] at: 08:11:25.186 Url is: /composer/admin/ping
(node:18241) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error trying to ping. Error: Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: The business network has been undeployed)
[5] at: 08:11:34.393 Url is: /composer/admin/deploy
business network zerotoblockchain-network.bna deployed successful:
[6] at: 08:11:44.211 Url is: /composer/admin/ping
(node:18241) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Error trying to ping. Error: Error trying to query chaincode. Error: chaincode error (status: 500, message: Error: The business network has been undeployed)
This indicates that the composer deploy function is not actually deploying the network, even though I appear to receive a successful completion message from the deploy service. Help, please?
When you undeploy a business network, all it does is mark the business network as unreachable. It remains deployed and still running. The reason for this is that currently Hyperledger fabric provides no mechanism for shutting down instantiated chaincode. So all we can do is mark it as unusable.
The deploy API and command are the old way to get a business network up and running. The new way is the install/start combination. The reason that deploy reports successful is that it has to make decisions about errors reported back by both the install and start commands in order to continue to work in an expected manner in the Hyperledger Fabric way of doing things. So although it reports a success for deploying, it's really doing nothing because it is already deployed.
Related
I am getting the below error while trying to deploy any nodejs based chaincode on hyperledger 1.4 network :
Error: could not assemble transaction, err proposal response was not
successful, error code 500, msg timeout expired while starting
chaincode
I have even tried the base example chaincode_example02, that is also giving the same error.
Please help.
Hell everyone, I am trying to setup a multi-org hyperledger fabric network and I run it already successfully. But when I tried to connect using Node SDK to fabric network to get some data. I am facing below error, I suspect that it is because of the tls cert file but I dont exactly know whats the problem. Hope someone can help me on this. See below details:
Error:
var peer = fabric_client.newPeer(
'grpcs://localhost:7051', {
'pem': 'somepath/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem'
});
channel.addPeer(peer);
I have Hyperledger Fabric running using the byfn.sh script and I’m trying to use the node SDK to write a transaction.
In my setup I a new User object using my Admin private key and certificate and call client.setUserContext with that User.
I call channel.sendTransactionProposal successfully and follow up with a successful call to channel.sendTransaction.
I’m trying to get to a point where I can call event_hub.registerTxEvent to find out when the transaction is written on the peers, but I get an error. My code looks like this:
event_hub = client.getEventHubsForOrg()[0]
event_hub.connect()
event_hub.registerTxEvent(tx_id.getTransactionID(), (tx, code) => {
// This never executes
}, (err) => {
// An error occurs
})
I get the error:
Error: 2 UNKNOWN: event message validation failed: [failed deserializing event creator: [could not decode the PEM structure]]
It seems the error comes from the Peer when the event hub tries to send a register message and the peer can’t decode it.
Any idea what I am doing wrong?
I am running a node script which connects to the business network and adds assets to the network.
I get the below error.
Error: Error trying invoke business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: Received message larger than max (5153800 vs. 4194304)
at _initializeChannel.then.then.then.then.catch (/home/sneha/node-app-v1/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:916:34)
at <anonymous>
I followed this solved issue: https://jira.hyperledger.org/browse/FAB-3301
and changed remote.js file in respective node modules [ composer-playground,composer-client,composer-admin,composer-common etc.. ]
Even after the changes, I can't add the asset through the node script. It throws the same error.
If I add the asset through composer playground it successfully adds the asset but then I can't access the network [ in composer playground ] it throws this error
Error: No connection found with ID 2db7d182-8856-44d5-a9d8-5f7178726423
How can I solve both errors?
How can I set the limit to infinite?
I am using:
Node version: v8.9.4
Composer version: v0.16.5
To change grpc message limits requires you to create/update your connection profile. See https://hyperledger.github.io/composer/reference/connectionprofile
for information about connection profiles.
A no connection profile with id found usually implies you have restarted playground, but not restarted your interaction with playground. Would suggest closing the playground tab and creating new tab to use playground in.
Using the hyperledger-composer NodeJS SDK at latest levels. Attempting to ping network using the provided example code in composer-admin ping
var fs = require('fs');
var path = require('path');
var composer = require('composer-admin');
var composerClient = require('composer-client');
var composerCommon = require('composer-common');
var adminConnection = new composer.AdminConnection();
adminConnection.connect(config.composer.connectionProfile, config.composer.adminID, config.composer.adminPW)
.then(function(){
adminConnection.ping()
.then(function(result){
console.log("network ping successful: ",result);
res.send({ping: result});
})
.catch(function(error){
var _error = error;
console.log("network ping failed: "+_error);
res.send({ping: _error.toString()});
});
});
When executing this command, get the following response:
Error: error trying to ping.
Error: error trying to query chaincode.
Error: Missing "chaincodeId" parameter in the proposal request
However, the ping command takes no parameters. Help, please?
Inspecting the composer-admin code, shows that the security context is evaluated prior to a ping. When I look at the security context object returned by the new composer.AdminConnection() request, the network identifier object is empty - undefined. If I update that field with my network identifier using the following code
adminConnection.securityContext.connection.businessNetworkIdentifier = "zerotoblockchain-network#0.1.6";
the error messages change to:
Error: error trying to ping.
Error: error trying to query chaincode.
Error: could not find chaincode with name 'zerotoblockchain-network#0.1.6' - make sure the chaincode zerotoblockchain-network#0.1.6 has been successfully instantiated and try again
Using the admin interface to list networks returns this network as deployed. Don't understand why the message is about chaincode when the update was to the network identifier as created by the composer archive and deployed via the composer deploy services.
Whether or not this was a bug, it's been resolved in the latest version of composer (v0.12). Highly recommend removing version numbers from package.json file for all composer node modules as these are updated VERY frequently and version mismatches are generating many spurious erros.