Hyperledger fabric application-javascript error using client server model in app.js

Viewed 94

https://github.com/hyperledger/fabric-samples In the file app.js in director asset-transfer-basic->application-javascript when I insert the code of server to listen on a port and try to call the contract it gives out the error as follows. enter image description here

                connection.write(data.toString());
                console.log('Sent response to client');
                connection.end();
                console.log('Disconnected the client.');
           });
        
        });
        
        
        server.listen(port, function () {
            console.log('server is listening');
        }); 
        console.log('\n--> Evaluate Transaction: GetSignedRank, function returns signed rank');
        var result = await contract.evaluateTransaction('GetSignedRank', '123');
        console.log(result.toString());
        //console.log(`*** Result: ${prettyJSONString(result.toString())}`);
    } finally {
        // Disconnect from the gateway when the application is closing
        // This will close all connections to the network
        gateway.disconnect();
    }
} catch (error) {
    console.error(`******** FAILED to run the application: ${error}`);
}

}

the problem is in this line var result = await contract.evaluateTransaction('GetSignedRank', '123');

1 Answers

I solved it by making a separate nodejs file and calling a duplicate of file app.js which allowed to call the evaluateTransaction method.I think the error was the connection was ended in the server code before I called the evaluateTransaction

Related