hyperledger-composer nodejs sdk ping fails

287 Views Asked by At

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 = "[email protected]";

the error messages change to:

Error: error trying to ping. 
Error: error trying to query chaincode. 
Error: could not find chaincode with name '[email protected]' - make sure the chaincode [email protected] 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.

1

There are 1 best solutions below

0
On BEST ANSWER

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.