1 year ago

#257815

test-img

maxkart

Hyperledger K8 Network - Nodejs application

I am running a HLF samples k8 network locally (kind/ network up).

enter image description here

Now in the nodejs app on the host machine

   const gateway = new Gateway();
    
            const gatewayOpts: GatewayOptions = {
                wallet,
                identity: this.org1UserId,
                discovery: { enabled: true, asLocalhost: true }, // using asLocalhost as this gateway is using a fabric network deployed locally
            };
    
            try {
                // setup the gateway instance
                // The user will now be able to create connections to the fabric network and be able to
                // submit transactions and query. All transactions submitted by this gateway will be
                // signed by this user using the credentials stored in the wallet.
                console.log('Trying to connect now ...');
                await gateway.connect(ccp, gatewayOpts);
                console.log('Connection established');
                // Build a network instance based on the channel where the smart contract is deployed
                const network = await gateway.getNetwork(this.channelName);
                console.log('network', network);

Connection error

Loaded the network configuration located at /Users/tdhillon/Workspace/block-chain/lynx/hlf-k8-network/build/fabric-rest-sample-config/HLF_CONNECTION_PROFILE_ORG1
Built a CA Client named org1-ecert-ca
Built a file system wallet at /Users/tdhillon/Workspace/block-chain/lynx/hlf-server-app/wallet
Trying to connect now ...
2022-03-06T11:00:30.567Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: org1-peer1, url:grpcs://org1-peer1:7051, connected:false, connectAttempted:true
2022-03-06T11:00:30.568Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server org1-peer1 url:grpcs://org1-peer1:7051 timeout:3000
2022-03-06T11:00:30.592Z - info: [NetworkConfig]: buildPeer - Unable to connect to the endorser org1-peer1 due to Error: Failed to connect before the deadline on Endorser- name: org1-peer1, url:grpcs://org1-peer1:7051, connected:false, connectAttempted:true
    at checkState (/Users/tdhillon/Workspace/block-chain/lynx/hlf-server-app/node_modules/@grpc/grpc-js/src/client.ts:172:18)
    at Timeout._onTimeout (/Users/tdhillon/Workspace/block-chain/lynx/hlf-server-app/node_modules/@grpc/grpc-js/src/channel.ts:707:9)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7) {
  connectFailed: true
}

I think the issue is because the hostmachine isn't able to connect to the pods in the test-network.

  1. Is there was a way for the hostmachine to access the services through the dns names e.g. 'org1-peer1'
  2. Are there any other ways of establishing a development environment ??

Any suggestions are much appreciated.

Thanks

node.js

kubernetes

hyperledger-fabric

hyperledger-chaincode

0 Answers

Your Answer

Accepted video resources