I am having an issue in the Hyperledger fabric Node SDK.
Network Details:
The network consists of 4 organisations each deployed on different Kubernetes cluster.
Each organisation has 2 peers which joined a single channel say mychannel.
Each organisation has 1 CA running.
Ordering service is Raft.
CouchDB is used as statedb.
The invokes from the CLI are also working fine and the data is being synced between all the 8 peers.
Hypelredger explorer is up and running with the one organisation details and is able to list all the other 6 peers in the dashboard.
Now back to issue, I tried to deploy the Node.js SDK for Org1.
I created a connection profile having the details of the Org1 Peers, Orderer and CA.
The users are enrolled (Admin and user1).
Now when I try to invoke transaction there are two cases:
Service discovery enabled: In this case, the SDK tries to communicate with the other peers in the network and creator org peers but all returns the context deadline exceed error.
Service discovery disabled: Invokes successful.
I have no idea why the invoke transactions are failed when the service discovery is enabled.
The above issue is resolved when I added the host aliases into my /etc/hosts file.
I need to add the host names and IP for each peer in the /etc/hosts files.
After adding the host names, the SDK started working.
Thanks
Could be your anchor peers are configured incorrectly, since discovery reports those, and some clients will use them.
Related
I have a Hyperledger-Fabric network with two organisations: Org1 and Org2.
The service discovery is disabled.
When organization 1 submits a transaction in a channel, can he designate endorsing peer of other organizations in the channel to endorse it?
How to do it? Since the service discovery is disabled, organization1 may generate peer info from the channel config block?
It would help to say which client API and/or language you are using.
With discovery disabled, your client is only going to know about the nodes defined in the connection profile that it uses to connect to the network. For a Node client, you can use setEndorsingOrganizations() or setEndorsingPeers() on the Transaction object. For Java you can use setEndorsingPeers() on the Transaction object. For Go you can use the WithEndorsingPeers option.
I would recommend configuring discovery in your network and using it in your clients. You will need to have discovery enabled to use the new Fabric Gateway service and Fabric Gateway client API introduced with Fabric v2.4. If you can use that, I would highly recommend it instead of the legacy SDKs.
We are setting up a multi-Org network, and have Anchor Peers defined and installed. We understand that Anchor Peers are used in peer discovery, but one question remains open: When a client needs to collect endorsements, how does it discover peers in the other Org to direct proposals to for endorsement? Is the Anchor Peer a "directory service" (and if so, how do we read the directory from the client SDK), or is it a "gateway" (and if so, how do we say how many endoresments we are trying to gather)?
When a client needs to collect endorsements, how does it discover
peers in the other Org to direct proposals to for endorsement?
Excellent question. There is a document for that.
Pasting below the relevant part:
The service runs on peers – not on the application – and uses the network metadata information maintained by the gossip communication layer to find out which peers are online. It also fetches information, such as any relevant endorsement policies, from the peer’s state database.
With service discovery, applications no longer need to specify which peers they need endorsements from. The SDK can simply send a query to the discovery service asking which peers are needed given a channel and a chaincode ID.
In a nutshell, starting from Fabric v1.2, the SDK can query a peer for the peers it needs to request endorsements from.
Is the Anchor Peer a "directory service"
No, it is not. The idea is that starting from Fabric v1.2, every peer that you trust as a client (i.e - a peer that belongs to your own organization) can serve your SDK as a discovery service endpoint.
There is also a brand new (friendly to use!) CLI tool that is included in v1.2 and can be used to query the discovery service on a peer.
There should be documentation published for the various SDKs once v1.2 is released.
or is it a "gateway" (and if so, how do we say how many endoresments
we are trying to gather)?
It is also not a gateway, it's only used for peers to bootstrap their membership view when they startup or join a channel.
I am working on setting up a Business Network for Multiple Organizations (two physical machines).
I did the setup of a business network using Hyperledger Composer Playground and achieved querying, rest-server implementation etc.
I have configured a multi-org (multiple organizations) setup for a single business network in a single cloud server (Reference link used: https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-multi-org). But, as in real scenario, I want to configure a multi-org functionality with two separate cloud servers.
I met with an error like below.
Error: Unable to Communicate with Peers. Peers not found.
Version of Composer : latest
Version of Fabric : V1.0
Thanks in Advance.
If you are using Composer latest (v0.19) then you have to use Fabric v1.1.
If you are Running on 2 servers with 2 IP addresses you need to solve the communications (IP Addressing and Routing) between you client and the servers, and between the containers on each server.
For the client to server you need to manage the addresses in the connection.json files for composer.
For the connectivity between the Peers and other containers the correct solution is to use Kubernetes or Docker Swarm to manage the addressing/routing. It is possible to use the extra_hosts feature of docker-compose for a simple demo but you might be restricted to one peer per org because of port conflicts.
I have deployed a one org hyperledger fabric network over docker swarm. Where one node has an orderer, peer , ca and couchdb and other node has one couchdb and node. I was able to invoke basic chaincode over it. Now I want to deploy composer over it. But I am not sure what shall I give in request and event url of connection.json. I already tried giving individual IPs instead of localhost,but no luck. I used this tutorial to deploy one org fabric network over docker swarm.
See https://discourse.skcript.com/t/setting-up-a-blockchain-business-network-with-hyperledger-fabric-composer-running-in-multiple-physical-machine/602
you will need the requestURL and eventURL definition, along with peer addresses from the other 'node' (I assume you mean 'machine') on your node 1.
I implemented hyperledger composer tutorial and create a simple business network definition and deploy it on through composer and implement it's rest API's through composer-rest-server. Now I want to add one more peer to it on a different local machine which can access blockchain I created previously, so my question is How can I achieve that a different peer node (another local machine) connected to blockchain I created in the composer tutorial?
you can check the S/Overflow link provided by Ahmed Nasser relating to adding your peer to an existing Fabric network.
Once you have your Fabric network up and running, and all of your network configuration / resolution / docker configuration tested and working, you can come to Composer to define the connection info, such as adding additional peers (and therefore create the requisite business network cards that contain that info).
This single organisation tutorial can give you an idea of what's involved - it builds upon a Fabric network that was already created (a simple, one-peer Fabric blockchain Dev environment) ..see here -> https://hyperledger.github.io/composer/tutorials/deploy-to-fabric-single-org.html
It obviously refers to 'localhost' in this scenario - obviously, you are creating something on an IP network, so you will need IP addresses/ host resolution as appropriate.