No peers provided by network with hyperledger app on android

418 Views Asked by At

With the Commercial paper tutorial, I continue to try to implement the java application to an Android emulator.

On Issue.java, when call Network network = gateway.getNetwork("mychannel"); an error occur : IllegalArgumentException: No peers provided.

Because of network argument by getChaincodeQueryPeersForOrganization(DefaultQueryHandlers.java:50), he don't give me a collection of peers and cause error on SingleQueryHandler.java:29.

I think about connection-org2.yaml file, but don't see what's wrong. (Default Java app not work correctly)

How can I give the right network, with correct peers ?

Complete error:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: iti.paper.ch.paper_test, PID: 9568
    java.lang.IllegalArgumentException: No peers provided
        at org.hyperledger.fabric.gateway.impl.query.SingleQueryHandler.<init>(SingleQueryHandler.java:29)
        at org.hyperledger.fabric.gateway.DefaultQueryHandlers.lambda$static$0(DefaultQueryHandlers.java:30)
        at org.hyperledger.fabric.gateway.-$$Lambda$DefaultQueryHandlers$A9xv6yy6Ls07YnjWxZKkScD7PTQ.create(Unknown Source:0)
        at org.hyperledger.fabric.gateway.DefaultQueryHandlers.create(DefaultQueryHandlers.java:73)
        at org.hyperledger.fabric.gateway.impl.NetworkImpl.<init>(NetworkImpl.java:54)
        at org.hyperledger.fabric.gateway.impl.GatewayImpl.getNetwork(GatewayImpl.java:252)
        at iti.paper.ch.paper_test.Issue.main(Issue.java:56)
        at iti.paper.ch.paper_test.MainActivity$1.onClick(MainActivity.java:29)
1

There are 1 best solutions below

1
On

Your SDK uses the connection-org2.yaml to populate the a view of the network to a large degree on the client side. The rest is taken care of by service discovery, should there be any changes subsequently.

Having said that, you should add your channel details in your connection profile (connection-org2.yaml) and specify the roles of the peers. The error that you are seeing is related to the fact that there are no peers defined with chaincode querying roles. You do that by modiying the connection profile and including details similar to this..

  channels: //name if the channel
    mychannel:
     peers:
      peer0.org2.example.com:
       endorsingPeer: false //this is a role
       chaincodeQuery: true //this is a role
       discover: true // this is a role
      peer1.org2.example.com:
       endorsingPeer: false
       chaincodeQuery: true
       discover: true

Try this and restart your network. Bear in mind that the default scripts will also regenate any connection profles using the template.