sendPeersProposal - Promise is rejected: Error: Failed to connect before the deadline - hyperledger-fabric

Hell everyone, I am trying to setup a multi-org hyperledger fabric network and I run it already successfully. But when I tried to connect using Node SDK to fabric network to get some data. I am facing below error, I suspect that it is because of the tls cert file but I dont exactly know whats the problem. Hope someone can help me on this. See below details:
Error:
var peer = fabric_client.newPeer(
'grpcs://localhost:7051', {
'pem': 'somepath/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem'
});
channel.addPeer(peer);

Related

Fabcar Tutorial - Error: error sending transaction for invoke: could not send: EOF

I am trying to launch the sample Fabcar tutorial network using the command "./startFabric.sh javascript" but unfortunately getting the below error at the last step while submitting initLedger transaction to smart contract on mychannel.
So when I query the ledger, it doesn't return anything.
can somebody advise whats wrong with my test network? Kindly let me know if you need additional details.
Error: error sending transaction for invoke: could not send: EOF - proposal response: version:1 response: payload:"\n \242tu\327\261\372F\2679&\205\027\010\255\323\025]\300~\273`\202\316\031zx\316\237\035\333\364\022\356\007\n\327\007\0227\n\n_lifecycle\022)\n'\n!namespaces/fields/fabcar/Sequence\022\002\010\005\022\233\007\n\006fabcar\022\220\007\032Y\n\004CAR0\032Q{"color":"blue","make":"Toyota","model":"Prius","owner":"Tomoko","docType":"car"}\032V\n\004CAR1\032N{"color":"red","make":"Ford","model":"Mustang","owner":"Brad","docType":"car"}\032]\n\004CAR2\032U{"color":"green","make":"Hyundai","model":"Tucson","owner":"Jin Soo","docType":"car"}\032]\n\004CAR3\032U{"color":"yellow","make":"Volkswagen","model":"Passat","owner":"Max","docType":"car"}\032V\n\004CAR4\032N{"color":"black","make":"Tesla","model":"S","owner":"Adriana","docType":"car"}\032Z\n\004CAR5\032R{"color":"purple","make":"Peugeot","model":"205","owner":"Michel","docType":"car"}\032W\n\004CAR6\032O{"color":"white","make":"Chery","model":"S22L","owner":"Aarav","docType":"car"}\032W\n\004CAR7\032O{"color":"violet","make":"Fiat","model":"Punto","owner":"Pari","docType":"car"}\032Y\n\004CAR8\032Q{"color":"indigo","make":"Tata","model":"Nano","owner":"Valeria","docType":"car"}\032\n\004CAR9\032T{"color":"brown","make":"Holden","model":"Barina","owner":"Shotaro","docType":"car"}\032\003\010\310\001"\r\022\006fabcar\032\0031.0" e
This issue has been resolved. I had downloaded the fabric samples twice on my PC which might have caused the issue. I deleted everything and downloaded the samples again before trying again and it worked!!

Timeout while deploying nodejs based chaincode

I am getting the below error while trying to deploy any nodejs based chaincode on hyperledger 1.4 network :
Error: could not assemble transaction, err proposal response was not
successful, error code 500, msg timeout expired while starting
chaincode
I have even tried the base example chaincode_example02, that is also giving the same error.
Please help.

How to resolve timeout error while executing transactions in hyperledger fabric?

I'm trying to insert bulk data in to blockchain. For 11,000 records records the insert is happening without any fault. But if I try to insert more, Im getting the following error.
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: 2 UNKNOWN: Error executing chaincode: Failed to execute transaction (Timeout expired while executing transaction)
Im using fabric sdk. My fabric verion is 1.2. Can anybody say how to resolve this?
Try to increase the timeout the timeout value. If this dont work, check the chaincode container logs.
Nodejs SDK example

Hyperledger fabric 1.2 service discovery error

I use Hyperledger Fabric 1.2 to build a blockchain cluster, which contains 3 peers and 3 orderers. I can successfully deploy and invoke the chaincode via both CLI and Java SDK. Everything works fine. However, when I notice the service discovery function and try to use it, I met two problems. First, after I build the discover tool and try to use it to get some discovered information, I can't access the peer and get the message as follow
"failed connecting to discovery service: failed to create new
connection: context deadline exceeded"
The config command is
discover --configFile conf.yaml --userKey ./crypto-config/peerOrganizations/org1.forchain.com/peers/peer0.org1.forchain.com/msp/keystore/7458b29b1fb6a89768585430dbf0e522a40ff4aefe600fc1e4fafe62c3c972e4_sk --userCert ./crypto-config/peerOrganizations/org1.forchain.com/peers/peer0.org1.forchain.com/msp/signcerts/peer0.org1.forchain.com-cert.pem --MSP Org1MSP saveConfig
The query command is
discover --configFile conf.yaml peers --channel lajiao --server localhost:6051
I guess it may be caused by the TLS config so I canceled the TLS and tried again. This time I successfully access the peer and get some messages, but I met another problem. When I use 'discover peers xxx ' command, I always get null result, in fact there are two peers in that channel. When I use 'discover endorsers xxx' command, I always get the following error message
'failed constructing descriptor for chaincodes:'
In the meantime, the peer log outputs the following message:
'Principal set computation failed: chaincode isn't installed on
sufficient organizations required by the endorsement policy 2018-08-01
10:21:50.860 UTC [discovery] chaincodeQuery -> ERRO 1441 Failed
constructing descriptor for chaincode chaincodes:
,: chaincode isn't installed on sufficient organizations required by
the endorsement policy'
I can assure that the chaincode is successfully installed in all peers. And I didn't use the endorsement policy when I instantiated the chaincode. I think it is not the policy problem because I still can invoke the chaincode and propose a transaction.
I also tried to use the Java SDK and found that I can get the orderer nodes info but I can't get the other peer nodes or chaincode info. The log always output: "Discover of chaincode names was empty.". But the chaincode is definitely instantiated and can be invoke via SDK. I refered to the test code in "org.hyperledger.fabric.sdkintegration.ServiceDiscoveryIT" and some key Java code is as follow:
channel.addPeer(peer, createPeerOptions().setPeerRoles(EnumSet.of(Peer.PeerRole.SERVICE_DISCOVERY,Peer.PeerRole.LEDGER_QUERY, Peer.PeerRole.EVENT_SOURCE,Peer.PeerRole.CHAINCODE_QUERY)));
channel.initialize();
System.out.println("================ orderer ===============");
for (Orderer orderer : channel.getOrderers()) {
System.out.println(orderer.getName());
}
System.out.println("================ peer ===============");
for (Peer p: channel.getPeers()) {
System.out.println(p.getName());
}
System.out.println("================ chaincode ===============");
for (String s: channel.getDiscoveredChaincodeNames()) {
System.out.println(s);
}
So, how can I use the 'discover' command under TLS configuration and how can I get the discovered information?
For the config command - you need to pass a TLS root CA, via --peerTLSCA. Please look at the examples in the documentation and act accordingly.
Now - for the second problem, I think that the peers might not know each other in the channel.
Make sure you have anchor peers defined in the channel and that both peers have external endpoints configured.
Feel free to bug me (yacovm) on chat.hyperledger.org if you're struggling for too long and can't solve the problem.
You must add an anchor peer from each organization in the channel, this solved the problem for me. Anchor peers are required for the service discovery since the service discovery uses gossip protocol- thanks #yacovm
I stumbled a similar error (regarding to service discovery) as below.
Go Fabric Client logs:
Failed to get endorsing peers: error getting channel response for channel [myc]:
Discovery status Code: (11) UNKNOWN. Description: error received from Discovery Server:
failed constructing descriptor for chaincodes:<name:"mycc">
Peer logs:
Failed constructing descriptor for chaincode chaincodes:<name:"mycc" > ,:
cannot satisfy any principal combination
It's fixed when I provide CORE_PEER_GOSSIP_EXTERNALENDPOINT environment attribute with a correct value on peer's configuration (in docker yaml file in my case).
As I understood since this attribute is missing, discovery services running on peers failed to communicate with each other to have a conclusion of what current network looks like.

Using a hyper ledger network without tls causing timeout when invoking a chaincode

I am getting the below error when I invoke my smart contract
Error: Error endorsing invoke: rpc error: code = Unknown desc = Error
executing chaincode: Failed to execute transaction (Timeout expired while
executing transaction) - <nil>
I am able to query the chaincode and this chaincode has worked on networks with TLS but now without it Im getting the error.
We removed TLS as we were having troubles with grpc connections when making calls from the node SDK. So possibly we could hit two birds with one stone.
How to deal with this error above?
And how to deal with TLS in the node app when making GRPC calls.

Resources