0

I am having following error when trying to execute a transaction using the Discovery service from Fabric Java SDK

org.hyperledger.fabric.sdk.exception.ServiceDiscoveryException: The channel is not configured with any peers with the 'discover' role

I joined the channel using peer shell command, not the Fabric Java SDK. How can I configure that discover role in the channel once it is already joined?

Thanks

icordoba
  • 1,834
  • 2
  • 33
  • 60
  • You can check the following link for more details with another approach https://stackoverflow.com/questions/58709303/the-channel-is-not-configured-with-any-peers-with-the-discover-role?answertab=active#tab-top – iOS-Developer84 Feb 25 '20 at 11:18

2 Answers2

0

The concept of the discover role is a Fabric Java SDK concept. When you create your channel definition using the SDK and add a peer to it you would need to define that peer as having the discover role.

This is all handled for you if you use the fabric-gateway-java SDK package rather than the fabric-sdk-java package. The fabric-gateway-java package provides an easier entry into writing fabric client apps in java although not as powerful as using fabric-sdk-java.

david_k
  • 5,843
  • 2
  • 9
  • 16
  • OK, but is there a way to, once I create the channel using peer shell command, enable that "discover" role using fabric-sdk-java? How? (At the stage of the project we can't easily move to fabric-gateway-java now) – icordoba Feb 13 '20 at 11:55
  • It's all down to how you create your peer object your code, you need to define that peer object and give it the discover role. This discover role is purely a java-sdk concept. Nothing to do with the peer server. You can make discovery calls to any peer. It's just that the java-sdk expects to know which peers you want to invoke discovery to. – david_k Feb 13 '20 at 12:38
0

I came up with the exact missing part of code. Hope it helps someone with a similar issue. It was just a matter of adding the required peerRoles as @david_k comments:

I had:

channel.addPeer(peer);

and replacing it with this fixed the issue:

channel.addPeer(peer, createPeerOptions().setPeerRoles(EnumSet.of(PeerRole.SERVICE_DISCOVERY, PeerRole.LEDGER_QUERY, PeerRole.EVENT_SOURCE, PeerRole.CHAINCODE_QUERY)));
icordoba
  • 1,834
  • 2
  • 33
  • 60