I'm trying to use the service discovery feature in Fabric 1.4. My network is default, 2 organizations and 2 peers per organization. I try to invoke a chaincode via service discovery feature rather than setting specific target peers. (Before using the service discovery, I set specific endorsers in target properties of transaction proposal request object.)
To use the service discovery, I set discover: true
to peers in my connection profile. Then, simply I added below code to my invoke
function.
await channel.initialize({ discover: true, asLocalhost: true })
Following the tutorial in fabric-node-sdk document, I changed the ports of each peer to use service discovery in docker-compose
network.
Everything works fine including creating the channel, installing chaincode, and instantiating chaincode. Also, invoking the chaincode works fine if I didn't use the service discovery feature.
However, if I added await channel.initialize({ discover: true, asLocalhost: true })
in my invoke
function, this initialize
function throws an error like below:
Error: No endorsement plan available for {"chaincodes":[{"name":"etri-bcdms-token-chaincode"}]}
(I set my endorsement policy during the instantiation)
In the peer, the below log are printed:
Failed constructing descriptor for chaincode chaincodes:<name:"etri-bcdms-token-chaincode" > ,: cannot satisfy any principal combination
The full code of my invoke function is below:
const client = this._useFabricCA
? await getUserClient(orgID, userID)
: await getOrgAdminClient(orgID)
if (!client) {
throw Error(`failed to get the client for ${orgID}`)
}
const channel = client.getChannel(channelID)
if (!channel) {
throw Error(`failed to get the channel for ${channelID}`)
}
// Service discovery
await channel.initialize({ discover: true, asLocalhost: true })
const chaincodeSetting = getChaincodeSetting(channelID)
if (!chaincodeSetting) {
throw Error(`no chaincode set on the channel ${channelID}`)
}
const txID = client.newTransactionID()
const request: ChaincodeInvokeRequest = {
// targets: targetList,
chaincodeId: chaincodeSetting.id,
fcn,
args,
txId: txID
}
// Process the endorsement
const results = await channel.sendTransactionProposal(request)
Is there any advice for this kind of error? Where can I invest to fix this error and use the service discovery? Any advice will be very thankful.