Transaction event is not emitted after successful invoke #fabric-sdk-node
Kumari Shweta
Hi Team,
I am using fabric node sdk api for events. Transaction (commitEvent) is not working.New block is generated successfully but transaction event is not emitted. Passing eventhandler option in gatewayoption in following way.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// await gateway.connect(ccp, { wallet, identity: appUser, discovery: { enabled: true, asLocalhost: true }, eventHandlerOptions: { commitTimeout: 300, strategy: DefaultEventHandlerStrategies.MSPID_SCOPE_ANYFORTX } // } }); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const listener = (error, event) => { console.log("event is called................"); if (error) { console.log("error========================",error); } else { // Handle transaction commit event } } const peers = network.getChannel().getEndorsers("Org1MSP"); const transaction = contract.createTransaction("createCar");
await network.addCommitListener(listener, peers, transaction.getTransactionId()); const result = await transaction.submit('createCar' ,'CAR1112', 'Honda', 'Accord', 'Black', 'Tom' ); console.log('Transaction has been submitted');
|
|
Mark Lewis
See the answer to the same question with nearly identical client code here: https://lists.hyperledger.org/g/fabric/topic/transaction_event_is_not/91619514
You are attaching your listener in the correct place, but it's listening for a transaction that is never submitted and is duplicating work that happens as part of the submit anyway. |
|
Mark Lewis
If you do want to provide your own implementation of how the client waits for a submitted transaction to be committed by network peers, this tutorial has some useful information:
https://hyperledger.github.io/fabric-sdk-node/release-2.2/tutorial-transaction-commit-events.html |
|