Kubernetes How to connect Node js SDK to Hyperledger Fabric network

0 votes

I have created 3 pods(statefulset)
1 .org-1 -->peer1 (acme-peer)

2.org2 -->peer2(budget-peer)

3.orderer(solo)

Use of cryptogen to generate crypto-material of network 

connection.json is mentioned below.

{

"name": "first-network-acme",

"version": "1.0.0",

"client": {

"organization": "acme",

"connection": {

"timeout": {

"peer": {

"endorser": "300"

}

}

}

},

"organizations": {

"peer1.acme.com": {

"mspid": "AcmeMSP",

"peers": [

"peer1.acme.com"

],

"certificateAuthorities": [

"ca.acme.com"

],

"adminPrivateKey":{

"path":"/var/hyperledger/users/Admin@acme.com/msp/keystore/priv_sk"

},

"signedCert":{

"path":"/var/hyperledger/users/Admin@acme.com/msp/signcerts/Admin@acme.com-cert.pem"

}

}

},

"orderers": {

"acme-orderer": {

"url": "grpc://172.17.0.3.default.svc.acme.orderer.com:30750",

"tlsCACerts": {

"pem": "-----BEGIN CERTIFICATE-----test-----END CERTIFICATE-----"

},

"grpcOptions": {

"ssl-target-name-override": "acme-orderer"

}

}

},

"peers": {

"peer1.acme.com": {

"url": "grpc://0.0.0.0:30751",

"tlsCACerts": {

"pem": "-----BEGIN CERTIFICATE-----test-----\n"

},

"grpcOptions": {

"ssl-target-name-override": "peer1.acme.com",

"hostnameOverride": "peer1.acme.com",

"grpc.keepalive_time_ms": 1200000

}

}

},

"certificateAuthorities": {

"ca.acme.com": {

"url": "http://0.0.0.0:30751",

"caName": "ca.acme.com",

"tlsCACerts": {

"pem": "-----BEGIN CERTIFICATE-----test-----\n"

},

"httpOptions": {

"verify": false

}

}

}

}

While running enrollAdmin.js getting the error :error: [FabricCAClientService.js]: Failed to enroll admin,Calling enroll endpoint failed with error [Error: Parse Error: Expected HTTP/]

Nov 12, 2020 in Blockchain by piyusha
• 170 points
455 views

Hi Gitika ,

I deleted package-lock.json and run the commands "npm install" and "npm install grpc".But still getting the error.

rror: [FabricCAClientService.js]: Failed to enroll admin, error:%o message=Calling enroll endpoint failed with error [Error: Parse Error: Expected HTTP/], stack=Error: Calling enroll endpoint failed with error [Error: Parse Error: Expected HTTP/].Failed to enroll admin user "admin": Error: Calling enroll endpoint failed with error [Error: Parse Error: Expected HTTP/]

Hi@piyusha,

Use the below command according to your pod. And see what happens.

$ kubectl port-forward pod/pod_name  :30751
@MD getting the same error as I mentioned above.

@Piyusha,

I had the exact same problem. This worked for me:

  • Open VirtualBox Manager and select the “default” VM
  • Click “Settings”, “Network”, “Advanced”, “Port Forwarding”.
  • Create a new rule by clicking the “+” sign on the right and entering the following: Name -> “ca”, Host Port -> 7054, Guest Port -> 7054.
  • You can leave the Host IP and Guest IP unspecified.

Source: https://developer.ibm.com/opentech/2017/11/29/running-hyperledger-fabric-windows-revised/

Thank you so much R Pradhan. But I m working with Ubuntu =18.04 ,Fabric version =2.2, minikube version =1.14.2. So the above case will not work for me.

1 answer to this question.

0 votes

Hey, @Piyusha,

Looks like the network did not come up.

Please check:

  • you are using the correctly tagged samples repo that matches the version of caliper you are using
  • you have built the crypto config for the network (as per samples repo readme)
  • all container instances with docker ps -a and associate logs for containers that are in error state via docker logs <container id>
answered Nov 12, 2020 by Gitika
• 65,870 points

Related Questions In Blockchain

0 votes
1 answer

Docker: How to connect Node.js in container to Hyperledger Fabric?

You need to map ~/.composer/cards of your Docker host ...READ MORE

answered Oct 31, 2018 in Blockchain by Omkar
• 69,110 points
465 views
+2 votes
3 answers
0 votes
1 answer
+2 votes
1 answer
+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer