简体   繁体   中英

hyperledger-composer nodejs sdk ping fails

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM