Hyperledger Fabric registerTxEvent fails with "could not decode the PEM structure" - hyperledger-fabric

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?

Related

Get transaction details by TxID in hyperledger farbic

I am currently running hyperledger fabric v2.2. I have developed the chaincode using the contractapi and developing the application using fabric-sdk-go/pkg/gateway
How can i get the transaction status and the transaction payload? I am aware of the GetHistoryByKey() which is available in the contractapi but that doesn't works out for my application.
I know there is hyperledger-explorer which can be used to search transactions by TxID but my use-case is my application will be querying by TxID and then it will verify the status of that particular transaction (TxID).
Also, i have tried to achieve this using the fabsdk but i am getting an error when i try to create instantiate the fabsdk using the fabsdk.New(). There seems to be some compatibility issue with the connection-profile.json which i am using the fabric-sample project.
The error which i am getting is:
failed to create identity manager provider: failed to initialize identity manager for organization: MyOrgName: Either a cryptopath or an embedded list of users is required
The same connection-profile has been used in getting the network up and running, and everything seems to be working all good. I am able to submit and evaluate transactions.
SOLUTION
The system chaincodes are embedded in the peer itself. so we need to set the target otherwise it would just give the discovery error since the contract QSCC is not explicitly deployed on the channel.
Make sure to check the core.yaml file channel.system - the system chaincode should be enabled channel.system.qscc: enable
qsccContract := network.GetContract("qscc")
txn, err := qsccContract.CreateTransaction("GetTransactionByID", gateway.WithEndorsingPeers("peer0.org1.com:8051"))
if err != nil {
fmt.Printf("Failed to create transaction: %s\n", err)
return
}
result, err := txn.Evaluate("mychannel", "4b1175335bdfe074d516a69df180ed6bc14591543eb26c10e21df2c67602b2dc")
if err != nil {
fmt.Printf("Failed to submit transaction: %s\n", err)
return
}
fmt.Println(string(result))
Note: The result needs to decoded to be human readable
Your client application can use the client SDK appropriate to your pogramming language to evaluate the GetTransactionByID transaction function on the qscc system chaincode, which is available on all peers. This transaction function takes a transaction ID as its only argument and returns a peer.ProcessedTransaction protobuf, which contains the transaction envelope and a validation code.

Problem with Wallet Creation, signature error

I want to create a wallet for new rest api server, but whenever I call code to generate new Wallet I'm getting error like
"Decoding SignatureHeader failed: Error illegal buffer ..."
Here is screen shot of my code, it is taken from virtual machine
I'm using hyperledger fabric 2.2 and run under the fabric-samples/test-network
I was clone this HyperledgerFabroc
Here is also print screen of the error:
I would appreciate if someone can navigate me how to manage successfully to create a wallet ?
Your error looks to be occurring within a chaincode transaction function. You should not be using the client SDK to do a transaction invocation from within chaincode. Instead look to use the invokeChaincode function on the stub:
https://hyperledger.github.io/fabric-chaincode-node/release-1.4/api/fabric-shim.ChaincodeStub.html#invokeChaincode

Timeout expired while querying large data on Hyperledger Fabric 1.4.1

I am using Hyperledger Fabric 1.4.1, with Kafka ordering service, Couch DB as stateDB, Java chaincode and Java SDK.
I experience timeout expired when I try to send large data to the channel and then query it back.
The data size of the transaction I sent is 512KB, and I can query it from peers.
I tried sending it 7 times with the same id, and I can get all 7 histories with shim function getHistoryForKey. But when I sent it 8 times with the same id, getHistoryForKey failed.
The error message is shown below (from peers):
Error: endorsement failure during query. response: status:500 message:"failed to execute transaction fdfbc5b72efd688136c777f5b114a3cedc62339e42f6c39a27e86ca11b8e3d14: error sending: timeout expired while executing transaction"
I have tried to expand the timeout with following options and their combinations in peer and client:
CORE_CHAINCODE_EXECUTETIMEOUT="120s"
CORE_LEDGER_STATE_COUCHDBCONFIG_REQUESTTIMEOUT="120s"
# (seems this setting is not for Hyperledger Fabric)
CORE_PEER_GRPCOPTIONS_REQUESET_TIMEOUT="120s"
But they didn't help in my case.
I also noticed that the 7 copies of testing data are about 3.5MB, and I tried to query 4MB data (which is about 8 copies) from a peer but failed.
When we check the chaincode runtime docker, we see the following error message:
SEVERE: An error occured on the chaincode stream. Shutting down the chaincode stream.
io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED:
io.grpc.netty.NettyClientTransport$3: Frame size 6294852 exceeds maximum: 4194304.
It seems like there is a grpc limitation on running the java chaincode docker.
We tested with go chaincode, we do not experience the same issue.
We managed to fix that by overriding the ChaincodeBase class
ManagedChannelBuilder<?> newChannelBuilder() throws IOException {
final NettyChannelBuilder builder = NettyChannelBuilder.forAddress(host, port);
logger.info("Configuring channel connection to peer.");
builder.maxInboundMessageSize(104857600);
logger.info("maxInboundMessageSize is 104857600.");
if (tlsEnabled) {
builder.negotiationType(NegotiationType.TLS);
builder.sslContext(createSSLContext());
} else {
builder.usePlaintext(true);
}
return builder;
}
I have submitted a ticket on fabric Jira to support changing the variable without overriding.

Timeout while deploying nodejs based chaincode

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.

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.

Resources