0

I'm trying to get trough the first demo "Writing Your First Application" https://hyperledger-fabric.readthedocs.io/en/release-1.2/write_first_app.html in Hyperledger Fabric. I successfully run the query part (queryAllCars and queryCar methods). I have a problem in Updating Ledger part. That's what I do:

  1. Put the values in invoke.js file:

    var request = {
    //targets: let default to the peer assigned to the client
    chaincodeId: 'fabcar',
    fcn: 'createCar',
    args: ['CAR10', 'Chevy', 'Volt', 'Red', 'Nick'],
    chainId: 'mychannel',
    txId: tx_id};
    
  2. Run node invoke.js and get in terminal:

Store path:/home/krystian/hyperledger-test/fabric-samples/fabcar/hfc-key-store

Successfully loaded user1 from persistence

Assigning transaction_id: 0dfca05d6f19187275c6a31febc81429ddca3a284fd590c631961a10f8da5aee

Transaction proposal was good

Successfully sent Proposal and received ProposalResponse: Status - 200, message - ""

Failed to invoke successfully :: Error: There was a problem with the eventhub ::14 UNAVAILABLE: TCP Write failed

at createStatusError (/home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:64:15)
at ClientDuplexStream._emitStatusIfDone (/home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:270:19)
at ClientDuplexStream._receiveStatus (/home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:248:8)
at /home/krystian/hyperledger-test/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/client.js:804:12

This is my package.json

{
"name": "fabcar",
"version": "1.0.0",
"description": "Hyperledger Fabric Car Sample Application",
"main": "fabcar.js",
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
    "fabric-ca-client": "^1.2.1",
    "fabric-client": "^1.2.1",
    "grpc": "^1.15.1"
},
"author": "Anthony O'Dowd",
"license": "Apache-2.0",
"keywords": [
    "Hyperledger",
    "Fabric",
    "Car",
    "Sample",
    "Application"
]

}

This is a part of invoke.js where it's crash:

        let event_hub = fabric_client.newEventHub();

    event_hub.setPeerAddr('grpc://localhost:7053');

    // using resolve the promise so that result status may be processed
    // under the then clause rather than having the catch clause process
    // the status
    let txPromise = new Promise((resolve, reject) => {
        let handle = setTimeout(() => {
            event_hub.disconnect();
            resolve({event_status : 'TIMEOUT'}); //we could use reject(new Error('Trnasaction did not complete within 30 seconds'));
        }, 3000);
        **event_hub.connect();
        event_hub.registerTxEvent(transaction_id_string, (tx, code) => {
            // this is the callback for transaction event status
            // first some clean up of event listener
            clearTimeout(handle);
            event_hub.unregisterTxEvent(transaction_id_string);**
            event_hub.disconnect();

I've tried to remove fabcar/node_modules and run npm install again. I've tried run sudo node invoke.js too. I finished tutorial Building Your First Network and everything was ok.

Node Version v8.9.0

NPM Version 5.5.1

I'm using Linux Mint

Where can be a problem with updating ledger, when initLedger method and querying works without problems?

  • I've tried to do the same on a new instance a Linux Mint and worked like a charm. But I'm still curious where I made a mistake on the first time. – krystian_sputo Oct 09 '18 at 06:53

1 Answers1

0

I get that error once again and I finally solved that. That was mismatch at grpc version. I used to have Hyperledger Fabric network v1.3.0 which use grpc@1.14.2 and my client application had set in package.json file the v.1.1.0 of fabric-client and v1.6.6 grpc.

After I've fixed that I get another error:

Failed to invoke successfully :: TypeError: fabric_client.newEventHub is not a function

But that error it's resolved here: unable to find newEventHub function.

So if you have the same problem you have to use the same version of packages in the network and the client app.