Reputation: 313
I am struggling with Node.js Hyperledger Fabric client library on this particular error:
I've got my blockchain network (Hyperledger Fabric 1.4) deployed on one server with IP and all needed ports visible from another server. All the examples / samples available in documentation are referring to network via localhost.
How it's possible to start the client application and point it to the IP address of the network instead of localhost or peer container names (e.g. peer0.org1.example.com)?
Does each client application have to enroll admin and user into its local persistence store or it can be done only once by the network itself (and probably mounted from network to application in later stage)? We talk here about Dockerized network on one host and client application (Dockerized as well) on another.
And also, how to start the application and connect to e.g. ordered via GRCPS if it requires the .pem certificate file being present when calling createPeer
method?
I will be very thankful for any help provided here.
EDIT, 12.03.2020:
I am using the basic-network sample with changes to my network to create 3 organizations with 3 peers each and 5 Raft orderers. I've copied the connection-org1.json file, changed localhost to my external server IP and I got the following error:
2020-03-12T12:45:31.503Z - error: [SingleQueryHandler]: evaluate: message=No peers available to query. Errors: ["14 UNAVAILABLE: DNS resolution failed","14 UNAVAILABLE: DNS resolution failed","14 UNAVAILABLE: DNS resolution failed"], stack=FabricError: No peers available to query. Errors: ["14 UNAVAILABLE: DNS resolution failed","14 UNAVAILABLE: DNS resolution failed","14 UNAVAILABLE: DNS resolution failed"]
at SingleQueryHandler.evaluate ((...)/network_files/javascript/node_modules/fabric-network/lib/impl/query/singlequeryhandler.js:44:17), name=FabricError
Failed to evaluate transaction: FabricError: No peers available to query. Errors: ["14 UNAVAILABLE: DNS resolution failed","14 UNAVAILABLE: DNS resolution failed","14 UNAVAILABLE: DNS resolution failed"]
I was able to successfully enroll and register admin and user on my local machine using the network hosted on external IP. But I cannot query the chaincode with the connection profile.
Here's my connection profile:
{
"name": "first-network-org1",
"version": "1.0.0",
"client": {
"organization": "Org1",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
}
}
}
},
"organizations": {
"Org1": {
"mspid": "Org1MSP",
"peers": [
"peer0.org1.example.com",
"peer1.org1.example.com",
"peer2.org1.example.com"
],
"certificateAuthorities": [
"ca.org1.example.com"
]
}
},
"peers": {
"peer0.org1.example.com": {
"url": "grpcs://<IP>:7051",
"tlsCACerts": {
"pem": "<CERT>"
},
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com",
"hostnameOverride": "peer0.org1.example.com"
},
"endorsingPeer": true,
"chaincodeQuery": true,
"ledgerQuery": true,
"eventSource": true
},
"peer1.org1.example.com": {
"url": "grpcs://<IP>:8051",
"tlsCACerts": {
"pem": "<CERT>"
},
"grpcOptions": {
"ssl-target-name-override": "peer1.org1.example.com",
"hostnameOverride": "peer1.org1.example.com"
}
},
"peer2.org1.example.com": {
"url": "grpcs://<IP>:9051",
"tlsCACerts": {
"pem": "<CERT>"
},
"grpcOptions": {
"ssl-target-name-override": "peer2.org1.example.com",
"hostnameOverride": "peer2.org1.example.com"
}
}
},
"certificateAuthorities": {
"ca.org1.example.com": {
"url": "https://<IP>:7054",
"caName": "ca-org1",
"tlsCACerts": {
"pem": "<CERT>"
},
"httpOptions": {
"verify": false
}
}
}
}
Upvotes: 1
Views: 978
Reputation: 367
In your connection-profile.yml
file which you'll use to connect to the network just change localhost
with host_ip
that should work fine.
Upvotes: 0
Reputation: 2200
If you are testing by using a docker service based on fabric-tools
image or similar, set CORE_PEER_ADDRESS
, CORE_PEER_LOCALMSPID
and CORE_PEER_ID
environment variables (between others).
If you are developing an application with an SDK, configure your connection profile: https://hyperledger-fabric.readthedocs.io/en/release-1.4/developapps/connectionprofile.html.
You normally enroll your own user in your client application. A privileged user or service registers the user and then you enroll the certificate in your app with the provided credentials. For a docker service based on fabric-tools
, configure CORE_PEER_MSPCONFIGPATH
environment variable. For a client app developed with a SDK, store your private key in a wallet (https://hyperledger-fabric.readthedocs.io/en/release-1.4/developapps/wallet.html).
For GRPCS, you need the organization's TLS CA certificate. CORE_PEER_TLS_ENABLED
and CORE_PEER_TLS_ROOTCERT_FILE
variables in your docker client or the suitable connection profile in your SDK based app.
Upvotes: 1