Not able to query the BYFN via fabric-sdk-go due to the error “ no endorsement combination…”
up vote
0
down vote
favorite
I am trying to use fabric-sdk-go to access the fabric network which is buid up via BYFN . 
I want to try to do the same thing as the cli command: 
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
but only get the error:
Failed to get endorsing peers: error getting endorsers from channel response: no endorsement combination can be satisfied.
The endorsement policy is:
-P "AND ('Org1MSP.peer','Org2MSP.peer')"
The client code is below:
configPath := "config-payment.yaml"
sdk, err := fabsdk.New(config.FromFile(configPath))
defer sdk.Close()
clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser("User1"), fabsdk.WithOrg(orgName))
client, err := channel.New(clientChannelContext)
args := byte{byte("a")}
_, err = client.Query(channel.Request{ChaincodeID: ccID, Fcn: "query", Args: args},
    channel.WithRetry(retry.DefaultChannelOpts))
if err != nil {
    log.Fatalf("Failed to query: %s", err)
}
And the config-payment.yaml is below:
    version: 1.0.0
client:
organization: org1
logging:
    level: info
cryptoconfig:
    path: fabric-network/first-network/crypto-config
credentialStore:
    path: "/tmp/state-store"
    cryptoStore:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp
BCCSP:
    security:
    enabled: true
    default:
    provider: "SW"
    hashAlgorithm: "SHA2"
    softVerify: true
    level: 256
tlsCerts:
    client:
    key:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.key
    cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.crt
channels:
_default:
    peers:
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    policies:
    queryChannelConfig:
        minResponses: 1
        maxTargets: 1
        retryOpts:
        attempts: 5
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    discovery:
        maxTargets: 2
        retryOpts:
        attempts: 4
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    eventService:
        resolverStrategy: PreferOrg
        balancer: Random
        blockHeightLagThreshold: 5
        reconnectBlockHeightLagThreshold: 8
        peerMonitorPeriod: 6s
mychannel:
    peers:
    peer0.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer0.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
organizations:
org1:
    mspid: Org1MSP
    cryptoPath:  peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem
    peers:
    - peer0.org1.example.com
    - peer1.org1.example.com
org2:
    mspid: Org2MSP
    cryptoPath:  peerOrganizations/org2.example.com/users/{username}@org2.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem
    peers:
    - peer0.org2.example.com
    - peer1.org2.example.com
Orderer:
    mspID: OrdererMSP
    cryptoPath: ordererOrganizations/example.com/users/{username}@example.com/msp
    peers:
    - orderer.example.com
orderers:
orderer.example.com:
    url: localhost:7050
    grpcOptions:
    ssl-target-name-override: orderer.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem
peers:
peer0.org1.example.com:
    url: localhost:7051
    eventUrl: localhost:7053
    grpcOptions:
    ssl-target-name-override: peer0.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer1.org1.example.com:
    url: localhost:8051
    eventUrl: localhost:8053
    grpcOptions:
    ssl-target-name-override: peer1.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer0.org2.example.com:
    url: localhost:9051
    eventUrl: localhost:9053
    grpcOptions:
    ssl-target-name-override: peer0.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
peer1.org2.example.com:
    url: localhost:10051
    eventUrl: localhost:10053
    grpcOptions:
    ssl-target-name-override: peer1.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
entityMatchers:
peer:
    - pattern: peer0.org1.example.com:7051
    urlSubstitutionExp: localhost:7051
    eventUrlSubstitutionExp: localhost:7053
    sslTargetOverrideUrlSubstitutionExp: peer0.org1.example.com
    mappedHost: peer0.org1.example.com
    - pattern: peer1.org1.example.com:7051
    urlSubstitutionExp: localhost:8051
    eventUrlSubstitutionExp: localhost:8053
    sslTargetOverrideUrlSubstitutionExp: peer1.org1.example.com
    mappedHost: peer1.org1.example.com
    - pattern: peer0.org2.example.com:7051
    urlSubstitutionExp: localhost:9051
    sslTargetOverrideUrlSubstitutionExp: peer0.org2.example.com
    mappedHost: peer0.org2.example.com
    - pattern: peer1.org2.example.com:7051
    urlSubstitutionExp: localhost:10051
    sslTargetOverrideUrlSubstitutionExp: peer1.org2.example.com
    mappedHost: peer1.org2.example.com
orderer:
    - pattern: orderer.example.com:7050
    urlSubstitutionExp: localhost:7050
    sslTargetOverrideUrlSubstitutionExp: orderer.example.com
    mappedHost: orderer.example.com
hyperledger-fabric hyperledger-fabric-sdk-go
add a comment |
up vote
0
down vote
favorite
I am trying to use fabric-sdk-go to access the fabric network which is buid up via BYFN . 
I want to try to do the same thing as the cli command: 
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
but only get the error:
Failed to get endorsing peers: error getting endorsers from channel response: no endorsement combination can be satisfied.
The endorsement policy is:
-P "AND ('Org1MSP.peer','Org2MSP.peer')"
The client code is below:
configPath := "config-payment.yaml"
sdk, err := fabsdk.New(config.FromFile(configPath))
defer sdk.Close()
clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser("User1"), fabsdk.WithOrg(orgName))
client, err := channel.New(clientChannelContext)
args := byte{byte("a")}
_, err = client.Query(channel.Request{ChaincodeID: ccID, Fcn: "query", Args: args},
    channel.WithRetry(retry.DefaultChannelOpts))
if err != nil {
    log.Fatalf("Failed to query: %s", err)
}
And the config-payment.yaml is below:
    version: 1.0.0
client:
organization: org1
logging:
    level: info
cryptoconfig:
    path: fabric-network/first-network/crypto-config
credentialStore:
    path: "/tmp/state-store"
    cryptoStore:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp
BCCSP:
    security:
    enabled: true
    default:
    provider: "SW"
    hashAlgorithm: "SHA2"
    softVerify: true
    level: 256
tlsCerts:
    client:
    key:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.key
    cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.crt
channels:
_default:
    peers:
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    policies:
    queryChannelConfig:
        minResponses: 1
        maxTargets: 1
        retryOpts:
        attempts: 5
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    discovery:
        maxTargets: 2
        retryOpts:
        attempts: 4
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    eventService:
        resolverStrategy: PreferOrg
        balancer: Random
        blockHeightLagThreshold: 5
        reconnectBlockHeightLagThreshold: 8
        peerMonitorPeriod: 6s
mychannel:
    peers:
    peer0.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer0.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
organizations:
org1:
    mspid: Org1MSP
    cryptoPath:  peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem
    peers:
    - peer0.org1.example.com
    - peer1.org1.example.com
org2:
    mspid: Org2MSP
    cryptoPath:  peerOrganizations/org2.example.com/users/{username}@org2.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem
    peers:
    - peer0.org2.example.com
    - peer1.org2.example.com
Orderer:
    mspID: OrdererMSP
    cryptoPath: ordererOrganizations/example.com/users/{username}@example.com/msp
    peers:
    - orderer.example.com
orderers:
orderer.example.com:
    url: localhost:7050
    grpcOptions:
    ssl-target-name-override: orderer.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem
peers:
peer0.org1.example.com:
    url: localhost:7051
    eventUrl: localhost:7053
    grpcOptions:
    ssl-target-name-override: peer0.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer1.org1.example.com:
    url: localhost:8051
    eventUrl: localhost:8053
    grpcOptions:
    ssl-target-name-override: peer1.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer0.org2.example.com:
    url: localhost:9051
    eventUrl: localhost:9053
    grpcOptions:
    ssl-target-name-override: peer0.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
peer1.org2.example.com:
    url: localhost:10051
    eventUrl: localhost:10053
    grpcOptions:
    ssl-target-name-override: peer1.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
entityMatchers:
peer:
    - pattern: peer0.org1.example.com:7051
    urlSubstitutionExp: localhost:7051
    eventUrlSubstitutionExp: localhost:7053
    sslTargetOverrideUrlSubstitutionExp: peer0.org1.example.com
    mappedHost: peer0.org1.example.com
    - pattern: peer1.org1.example.com:7051
    urlSubstitutionExp: localhost:8051
    eventUrlSubstitutionExp: localhost:8053
    sslTargetOverrideUrlSubstitutionExp: peer1.org1.example.com
    mappedHost: peer1.org1.example.com
    - pattern: peer0.org2.example.com:7051
    urlSubstitutionExp: localhost:9051
    sslTargetOverrideUrlSubstitutionExp: peer0.org2.example.com
    mappedHost: peer0.org2.example.com
    - pattern: peer1.org2.example.com:7051
    urlSubstitutionExp: localhost:10051
    sslTargetOverrideUrlSubstitutionExp: peer1.org2.example.com
    mappedHost: peer1.org2.example.com
orderer:
    - pattern: orderer.example.com:7050
    urlSubstitutionExp: localhost:7050
    sslTargetOverrideUrlSubstitutionExp: orderer.example.com
    mappedHost: orderer.example.com
hyperledger-fabric hyperledger-fabric-sdk-go
What was the endorsement policy of your chaincode?
– Tanmoy Krishna Das
Nov 23 at 9:54
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to use fabric-sdk-go to access the fabric network which is buid up via BYFN . 
I want to try to do the same thing as the cli command: 
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
but only get the error:
Failed to get endorsing peers: error getting endorsers from channel response: no endorsement combination can be satisfied.
The endorsement policy is:
-P "AND ('Org1MSP.peer','Org2MSP.peer')"
The client code is below:
configPath := "config-payment.yaml"
sdk, err := fabsdk.New(config.FromFile(configPath))
defer sdk.Close()
clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser("User1"), fabsdk.WithOrg(orgName))
client, err := channel.New(clientChannelContext)
args := byte{byte("a")}
_, err = client.Query(channel.Request{ChaincodeID: ccID, Fcn: "query", Args: args},
    channel.WithRetry(retry.DefaultChannelOpts))
if err != nil {
    log.Fatalf("Failed to query: %s", err)
}
And the config-payment.yaml is below:
    version: 1.0.0
client:
organization: org1
logging:
    level: info
cryptoconfig:
    path: fabric-network/first-network/crypto-config
credentialStore:
    path: "/tmp/state-store"
    cryptoStore:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp
BCCSP:
    security:
    enabled: true
    default:
    provider: "SW"
    hashAlgorithm: "SHA2"
    softVerify: true
    level: 256
tlsCerts:
    client:
    key:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.key
    cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.crt
channels:
_default:
    peers:
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    policies:
    queryChannelConfig:
        minResponses: 1
        maxTargets: 1
        retryOpts:
        attempts: 5
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    discovery:
        maxTargets: 2
        retryOpts:
        attempts: 4
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    eventService:
        resolverStrategy: PreferOrg
        balancer: Random
        blockHeightLagThreshold: 5
        reconnectBlockHeightLagThreshold: 8
        peerMonitorPeriod: 6s
mychannel:
    peers:
    peer0.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer0.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
organizations:
org1:
    mspid: Org1MSP
    cryptoPath:  peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem
    peers:
    - peer0.org1.example.com
    - peer1.org1.example.com
org2:
    mspid: Org2MSP
    cryptoPath:  peerOrganizations/org2.example.com/users/{username}@org2.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem
    peers:
    - peer0.org2.example.com
    - peer1.org2.example.com
Orderer:
    mspID: OrdererMSP
    cryptoPath: ordererOrganizations/example.com/users/{username}@example.com/msp
    peers:
    - orderer.example.com
orderers:
orderer.example.com:
    url: localhost:7050
    grpcOptions:
    ssl-target-name-override: orderer.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem
peers:
peer0.org1.example.com:
    url: localhost:7051
    eventUrl: localhost:7053
    grpcOptions:
    ssl-target-name-override: peer0.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer1.org1.example.com:
    url: localhost:8051
    eventUrl: localhost:8053
    grpcOptions:
    ssl-target-name-override: peer1.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer0.org2.example.com:
    url: localhost:9051
    eventUrl: localhost:9053
    grpcOptions:
    ssl-target-name-override: peer0.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
peer1.org2.example.com:
    url: localhost:10051
    eventUrl: localhost:10053
    grpcOptions:
    ssl-target-name-override: peer1.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
entityMatchers:
peer:
    - pattern: peer0.org1.example.com:7051
    urlSubstitutionExp: localhost:7051
    eventUrlSubstitutionExp: localhost:7053
    sslTargetOverrideUrlSubstitutionExp: peer0.org1.example.com
    mappedHost: peer0.org1.example.com
    - pattern: peer1.org1.example.com:7051
    urlSubstitutionExp: localhost:8051
    eventUrlSubstitutionExp: localhost:8053
    sslTargetOverrideUrlSubstitutionExp: peer1.org1.example.com
    mappedHost: peer1.org1.example.com
    - pattern: peer0.org2.example.com:7051
    urlSubstitutionExp: localhost:9051
    sslTargetOverrideUrlSubstitutionExp: peer0.org2.example.com
    mappedHost: peer0.org2.example.com
    - pattern: peer1.org2.example.com:7051
    urlSubstitutionExp: localhost:10051
    sslTargetOverrideUrlSubstitutionExp: peer1.org2.example.com
    mappedHost: peer1.org2.example.com
orderer:
    - pattern: orderer.example.com:7050
    urlSubstitutionExp: localhost:7050
    sslTargetOverrideUrlSubstitutionExp: orderer.example.com
    mappedHost: orderer.example.com
hyperledger-fabric hyperledger-fabric-sdk-go
I am trying to use fabric-sdk-go to access the fabric network which is buid up via BYFN . 
I want to try to do the same thing as the cli command: 
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
but only get the error:
Failed to get endorsing peers: error getting endorsers from channel response: no endorsement combination can be satisfied.
The endorsement policy is:
-P "AND ('Org1MSP.peer','Org2MSP.peer')"
The client code is below:
configPath := "config-payment.yaml"
sdk, err := fabsdk.New(config.FromFile(configPath))
defer sdk.Close()
clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser("User1"), fabsdk.WithOrg(orgName))
client, err := channel.New(clientChannelContext)
args := byte{byte("a")}
_, err = client.Query(channel.Request{ChaincodeID: ccID, Fcn: "query", Args: args},
    channel.WithRetry(retry.DefaultChannelOpts))
if err != nil {
    log.Fatalf("Failed to query: %s", err)
}
And the config-payment.yaml is below:
    version: 1.0.0
client:
organization: org1
logging:
    level: info
cryptoconfig:
    path: fabric-network/first-network/crypto-config
credentialStore:
    path: "/tmp/state-store"
    cryptoStore:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp
BCCSP:
    security:
    enabled: true
    default:
    provider: "SW"
    hashAlgorithm: "SHA2"
    softVerify: true
    level: 256
tlsCerts:
    client:
    key:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.key
    cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/tls/client.crt
channels:
_default:
    peers:
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    policies:
    queryChannelConfig:
        minResponses: 1
        maxTargets: 1
        retryOpts:
        attempts: 5
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    discovery:
        maxTargets: 2
        retryOpts:
        attempts: 4
        initialBackoff: 500ms
        maxBackoff: 5s
        backoffFactor: 2.0
    eventService:
        resolverStrategy: PreferOrg
        balancer: Random
        blockHeightLagThreshold: 5
        reconnectBlockHeightLagThreshold: 8
        peerMonitorPeriod: 6s
mychannel:
    peers:
    peer0.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org1.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer0.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
    peer1.org2.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
organizations:
org1:
    mspid: Org1MSP
    cryptoPath:  peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem
    peers:
    - peer0.org1.example.com
    - peer1.org1.example.com
org2:
    mspid: Org2MSP
    cryptoPath:  peerOrganizations/org2.example.com/users/{username}@org2.example.com/msp
    users:
    Admin:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem
    User1:
        cert:
        path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem
    peers:
    - peer0.org2.example.com
    - peer1.org2.example.com
Orderer:
    mspID: OrdererMSP
    cryptoPath: ordererOrganizations/example.com/users/{username}@example.com/msp
    peers:
    - orderer.example.com
orderers:
orderer.example.com:
    url: localhost:7050
    grpcOptions:
    ssl-target-name-override: orderer.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem
peers:
peer0.org1.example.com:
    url: localhost:7051
    eventUrl: localhost:7053
    grpcOptions:
    ssl-target-name-override: peer0.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer1.org1.example.com:
    url: localhost:8051
    eventUrl: localhost:8053
    grpcOptions:
    ssl-target-name-override: peer1.org1.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
peer0.org2.example.com:
    url: localhost:9051
    eventUrl: localhost:9053
    grpcOptions:
    ssl-target-name-override: peer0.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
peer1.org2.example.com:
    url: localhost:10051
    eventUrl: localhost:10053
    grpcOptions:
    ssl-target-name-override: peer1.org2.example.com
    keep-alive-time: 0s
    keep-alive-timeout: 20s
    keep-alive-permit: false
    fail-fast: false
    allow-insecure: false
    tlsCACerts:
    path: fabric-network/first-network/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
entityMatchers:
peer:
    - pattern: peer0.org1.example.com:7051
    urlSubstitutionExp: localhost:7051
    eventUrlSubstitutionExp: localhost:7053
    sslTargetOverrideUrlSubstitutionExp: peer0.org1.example.com
    mappedHost: peer0.org1.example.com
    - pattern: peer1.org1.example.com:7051
    urlSubstitutionExp: localhost:8051
    eventUrlSubstitutionExp: localhost:8053
    sslTargetOverrideUrlSubstitutionExp: peer1.org1.example.com
    mappedHost: peer1.org1.example.com
    - pattern: peer0.org2.example.com:7051
    urlSubstitutionExp: localhost:9051
    sslTargetOverrideUrlSubstitutionExp: peer0.org2.example.com
    mappedHost: peer0.org2.example.com
    - pattern: peer1.org2.example.com:7051
    urlSubstitutionExp: localhost:10051
    sslTargetOverrideUrlSubstitutionExp: peer1.org2.example.com
    mappedHost: peer1.org2.example.com
orderer:
    - pattern: orderer.example.com:7050
    urlSubstitutionExp: localhost:7050
    sslTargetOverrideUrlSubstitutionExp: orderer.example.com
    mappedHost: orderer.example.com
hyperledger-fabric hyperledger-fabric-sdk-go
hyperledger-fabric hyperledger-fabric-sdk-go
edited Nov 23 at 11:58
asked Nov 22 at 12:59
Moon
185
185
What was the endorsement policy of your chaincode?
– Tanmoy Krishna Das
Nov 23 at 9:54
add a comment |
What was the endorsement policy of your chaincode?
– Tanmoy Krishna Das
Nov 23 at 9:54
What was the endorsement policy of your chaincode?
– Tanmoy Krishna Das
Nov 23 at 9:54
What was the endorsement policy of your chaincode?
– Tanmoy Krishna Das
Nov 23 at 9:54
add a comment |
                                1 Answer
                                1
                        
active
oldest
votes
up vote
0
down vote
Afer debuging the code, I found the root cause was due to the "Exclude" filter:
func containsPeer(peers fab.Peer, peer fab.Peer) bool {
for _, p := range peers {
    if p.URL() == peer.URL() {
        return true
    }
}
return false
}
peers[3].url = localhost:7051
peer.url = peer0.org1.example.com:7051
I was blocked by a connection problem, so I set the URL as localhost instead of peer0.org1.example.com. So the peer0.org1 was excluded and hence got the error: getting endorsers from channel response: no endorsement combination can be satisfied.
add a comment |
                                1 Answer
                                1
                        
active
oldest
votes
                                1 Answer
                                1
                        
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Afer debuging the code, I found the root cause was due to the "Exclude" filter:
func containsPeer(peers fab.Peer, peer fab.Peer) bool {
for _, p := range peers {
    if p.URL() == peer.URL() {
        return true
    }
}
return false
}
peers[3].url = localhost:7051
peer.url = peer0.org1.example.com:7051
I was blocked by a connection problem, so I set the URL as localhost instead of peer0.org1.example.com. So the peer0.org1 was excluded and hence got the error: getting endorsers from channel response: no endorsement combination can be satisfied.
add a comment |
up vote
0
down vote
Afer debuging the code, I found the root cause was due to the "Exclude" filter:
func containsPeer(peers fab.Peer, peer fab.Peer) bool {
for _, p := range peers {
    if p.URL() == peer.URL() {
        return true
    }
}
return false
}
peers[3].url = localhost:7051
peer.url = peer0.org1.example.com:7051
I was blocked by a connection problem, so I set the URL as localhost instead of peer0.org1.example.com. So the peer0.org1 was excluded and hence got the error: getting endorsers from channel response: no endorsement combination can be satisfied.
add a comment |
up vote
0
down vote
up vote
0
down vote
Afer debuging the code, I found the root cause was due to the "Exclude" filter:
func containsPeer(peers fab.Peer, peer fab.Peer) bool {
for _, p := range peers {
    if p.URL() == peer.URL() {
        return true
    }
}
return false
}
peers[3].url = localhost:7051
peer.url = peer0.org1.example.com:7051
I was blocked by a connection problem, so I set the URL as localhost instead of peer0.org1.example.com. So the peer0.org1 was excluded and hence got the error: getting endorsers from channel response: no endorsement combination can be satisfied.
Afer debuging the code, I found the root cause was due to the "Exclude" filter:
func containsPeer(peers fab.Peer, peer fab.Peer) bool {
for _, p := range peers {
    if p.URL() == peer.URL() {
        return true
    }
}
return false
}
peers[3].url = localhost:7051
peer.url = peer0.org1.example.com:7051
I was blocked by a connection problem, so I set the URL as localhost instead of peer0.org1.example.com. So the peer0.org1 was excluded and hence got the error: getting endorsers from channel response: no endorsement combination can be satisfied.
edited Nov 24 at 14:06
answered Nov 24 at 13:54
Moon
185
185
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
 
But avoid …
- Asking for help, clarification, or responding to other answers.
 - Making statements based on opinion; back them up with references or personal experience.
 
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
 
But avoid …
- Asking for help, clarification, or responding to other answers.
 - Making statements based on opinion; back them up with references or personal experience.
 
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431595%2fnot-able-to-query-the-byfn-via-fabric-sdk-go-due-to-the-error-no-endorsement-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What was the endorsement policy of your chaincode?
– Tanmoy Krishna Das
Nov 23 at 9:54