Error while using node js sdk in hyperledger fabric? - node.js

I m using node sdk for hyperledger fabric.i got the below error while using apiserver.js file in sdk. It only happens if i excute same query multiple time.
2019-11-22T09:02:35.721Z - warn: [Query]: evaluate: Query ID "[object Object]" of peer "peer0.org1.example.com:7051" failed: message=transaction returned with failure: TypeError: Assignment to constant variable., stack=Error: transaction returned with failure: TypeError: Assignment to constant variable.
at self._endorserClient.processProposal (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/fabric-client/lib/Peer.js:140:36)
at Object.onReceiveStatus (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:1207:9)
at InterceptingListener._callNext (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/home/cybrosys/VIRUS/ERC-20-with-Hyperledger-Fabric/fabcar/javascript/node_modules/grpc/src/client_interceptors.js:845:24), status=500, , url=grpcs://localhost:7051, name=peer0.org1.example.com:7051, grpc.max_receive_message_length=-1, grpc.max_send_message_length=-1, grpc.keepalive_time_ms=120000, grpc.http2.min_time_between_pings_ms=120000, grpc.keepalive_timeout_ms=20000, grpc.http2.max_pings_without_data=0, grpc.keepalive_permit_without_calls=1, name=peer0.org1.example.com:7051, grpc.ssl_target_name_override=peer0.org1.example.com, grpc.default_authority=peer0.org1.example.com, isProposalResponse=true
Help will be appreciated!

The error you are receiving is tunneled from the chaincode to the sdk.
Essentially is not related to the SDK but the chaincode.
Go to the machine with Hyperledger installed, and open logs for the dev peer.
You will find the same error
[Query]: evaluate: Query ID "[object Object]" of peer "peer0.org1.example.com:7051" failed: message=transaction returned with failure: TypeError: Assignment to constant variable., stack=Error: transaction returned with failure: TypeError: Assignment to constant variable.
and you will get that the problem is related to the chaincode.
I don't know how did you write your contract, if Go or other languages, but the message is clear: you declared a const and you are assinging it a new value.
Check your code, re-deploy the contract and you solve.

Related

Getting error as Failed to evaluate transaction: Error: No event hubs for strategy

I have implemented the Raft network with TLS with three orderer and installed and initiated Go chaincode however when I am trying to invoke chaincode its giving me error
error: [AbstractStrategy]: constructor: No event hubs for strategy
Failed to evaluate transaction: Error: No event hubs for strategy
Please anybody help me as I am getting this issue first time.
Thanks in advance

Implementing Private Data Collection in Hyperledger Fabric 2.0 Error

I tried to implement the private data collections in fabric 2.0 network.I have faced error when I tried to invoke chaincode with the transient data flag.
And it is unable to recognize the method ("priv").
Error: endorsement failure during invoke. response: status:500 message:"error in simulation: transaction returned with failure: Error: You've asked to invoke a function that does not exist: priv"
The "priv" method in chaincode is fairly simple.It is using the putPrivateData() method to store the private data.
I have fixed it.The issue was related to the version of shim api in package.json of chaincode.

Hyperledger Fabric invokeChaincode

I want to invoke another chaincode inside a chaincode using ctx.stub.invokeChaincode("called chaincode name", ["the name of the function (transaction) of the called chaincode", args]), and my both chaincodes has been instantiated on the same channel, but I get the following error:
Calling chaincode Invoke() returned error response [Error: You've
asked to invoke a function that does not exist: Confirm.confirmData].
Sending ERROR message back to peer.
I am not sure if I am wrong with defining the list chainCode arguments.

Chaincode Query Transcation is not executing in EC2 Insance

please find the image first intsertion was happened sucessfully.I am trying to query my transaction in Amazon-EC2 but it is returning NULL with endorsement failure even though my insertion transaction is working fine in the local system.
This is the error I get:
endorsement failure during invoke. response: status:500 message:"transaction returned with failure: Error: {\"Error\":\"candidate does not exist with: 13VV1A0533\"}"
From the error it seems that the chaincode is missing error handling for scheduleInterview method.
What the error means is that there is no data for the key candidate id.
Do revert if this doesnt help.

How to resolve timeout error while executing transactions in hyperledger fabric?

I'm trying to insert bulk data in to blockchain. For 11,000 records records the insert is happening without any fault. But if I try to insert more, Im getting the following error.
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: 2 UNKNOWN: Error executing chaincode: Failed to execute transaction (Timeout expired while executing transaction)
Im using fabric sdk. My fabric verion is 1.2. Can anybody say how to resolve this?
Try to increase the timeout the timeout value. If this dont work, check the chaincode container logs.
Nodejs SDK example

Resources