Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when Event Listening using Fabric SDKs #116

Closed
mbwhite opened this issue Oct 27, 2022 · 3 comments
Closed

Errors when Event Listening using Fabric SDKs #116

mbwhite opened this issue Oct 27, 2022 · 3 comments

Comments

@mbwhite
Copy link
Contributor

mbwhite commented Oct 27, 2022

Found initially as part of hyperledger-caliper/caliper#1465

When using the 1.4.20 node sdk transactions would fail intermittently with

2022-10-26T18:56:34.416Z - error: [AbstractStrategy]: constructor: No event hubs for strategy
2022.10.26-18:56:34.417 +0000 error [connectors/v1/FabricGateway] Failed to perform submit transaction [queryMarblesByOwner] using arguments [Alice],  with error: Error: No event hubs for strategy
    at new AbstractEventStrategy (/tmp/sut/cached/v1.4.20/node_modules/fabric-network/lib/impl/event/abstracteventstrategy.js:30:10)
    at new AnyForTxStrategy (/tmp/sut/cached/v1.4.20/node_modules/fabric-network/lib/impl/event/anyfortxstrategy.js:23:1)
    at Transaction.MSPID_SCOPE_ANYFORTX [as _createTxEventHandler] (/tmp/sut/cached/v1.4.20/node_modules/fabric-network/lib/impl/event/defaulteventhandlerstrategies.js:37:24)
    at Transaction.submit (/tmp/sut/cached/v1.4.20/node_modules/fabric-network/lib/transaction.js:164:29)
    at V1FabricGateway._submitOrEvaluateTransaction (/home/runner/work/caliper/caliper/packages/caliper-fabric/lib/connector-versions/v1/FabricGateway.js:375:44)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async V1FabricGateway._sendSingleRequest (/home/runner/work/caliper/caliper/packages/caliper-fabric/lib/connector-versions/v1/FabricGateway.js:170:16)
    at async V1FabricGateway.sendRequests (/home/runner/work/caliper/caliper/packages/caliper-core/lib/common/core/connector-base.js:83:26)
    at async MarblesQueryWorkload.submitTransaction (/home/runner/work/caliper/caliper/packages/caliper-tests-integration/fabric_tests/query.js:48:9)

for the node 2.2 sdk the problem was similar with

2022-10-26T18:57:24.873Z - error: [TransactionEventStrategy]: constructor: No peers for strategy
2022.10.26-18:57:24.873 +0000 error [connectors/v2/FabricGateway] Failed to perform submit transaction [initMarble] using arguments [marbles_phase_4_0_1_10,black,10,Claire],  with error: Error: No peers for strategy
    at new TransactionEventStrategy (/tmp/sut/cached/v2.2.14/node_modules/fabric-network/lib/impl/event/transactioneventstrategy.js:49:19)
    at new AnyForTxStrategy (/tmp/sut/cached/v2.2.14/node_modules/fabric-network/lib/impl/event/anyfortxstrategy.js:41:1)
    at Transaction.MSPID_SCOPE_ANYFORTX [as eventHandlerStrategyFactory] (/tmp/sut/cached/v2.2.14/node_modules/fabric-network/lib/impl/event/defaulteventhandlerstrategies.js:60:27)
    at Transaction.submit (/tmp/sut/cached/v2.2.14/node_modules/fabric-network/lib/transaction.js:257:39)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async V2FabricGateway._submitOrEvaluateTransaction (/home/runner/work/caliper/caliper/packages/caliper-fabric/lib/connector-versions/v2/FabricGateway.js:375:26)
    at async V2FabricGateway._sendSingleRequest (/home/runner/work/caliper/caliper/packages/caliper-fabric/lib/connector-versions/v2/FabricGateway.js:168:16)
    at async V2FabricGateway.sendRequests (/home/runner/work/caliper/caliper/packages/caliper-core/lib/common/core/connector-base.js:83:26)
    at async MarblesInitWorkload.submitTransaction (/home/runner/work/caliper/caliper/packages/caliper-tests-integration/fabric_tests/init.js:72:9)

No problems like this occur when using test network or the fabric-gateway

@mbwhite
Copy link
Contributor Author

mbwhite commented Oct 28, 2022

Log from the SDK v2 immediately prior to the error


2022-10-28T09:37:34.257Z - debug: [DiscoveryHandler]: _modify_groups - updated endorsement_plan:{"chaincode":"yourmarbles","groups":{"G1":{"peers":[{"mspid":"Org2MSP","endpoint":"org2peer-api.127-0-0-1.nip.io:8080","name":"org2peer-api.127-0-0-1.nip.io:8080","ledgerHeight":{"low":5,"high":0,"unsigned":true},"chaincodes":[{"name":"yourmarbles","version":"1"},{"name":"_lifecycle","version":"1"}]}]},"G0":{"peers":[{"mspid":"Org1MSP","endpoint":"org1peer-api.127-0-0-1.nip.io:8080","name":"org1peer-api.127-0-0-1.nip.io:8080","ledgerHeight":{"low":5,"high":0,"unsigned":true},"chaincodes":[{"name":"yourmarbles","version":"1"},{"name":"_lifecycle","version":"1"}]}]}},"layouts":[{"G0":1},{"G1":1}],"endorsements":{}}
2022-10-28T09:37:34.257Z - debug: [DiscoveryHandler]: _endorse - starting layout plan 0
2022-10-28T09:37:34.257Z - debug: [DiscoveryHandler]: _endorse_layout - start
2022-10-28T09:37:34.257Z - debug: [DiscoveryHandler]: _build_endorse_group_member >> G0:0 - start
2022-10-28T09:37:34.257Z - debug: [DiscoveryService]: _buildUrl[yourmarbles] - start
2022-10-28T09:37:34.257Z - debug: [Channel]: getEndorsers[yourchannel] - start
2022-10-28T09:37:34.257Z - debug: [Channel]: _getServiceEndpoints - start - undefined
2022-10-28T09:37:34.257Z - debug: [Channel]: _getServiceEndpoints - Endorser added org2peer-api.127-0-0-1.nip.io:8080 connected: true
2022-10-28T09:37:34.257Z - debug: [DiscoveryHandler]: _build_endorse_group_member >> G0:0 - send endorsement to org1peer-api.127-0-0-1.nip.io:8080
2022-10-28T09:37:34.257Z - debug: [ServiceEndpoint]: checkConnection[Endorser-org2peer-api.127-0-0-1.nip.io:8080] - start - connected:true
2022-10-28T09:37:34.257Z - debug: [ServiceEndpoint]: waitForReady - start Endorser-org2peer-api.127-0-0-1.nip.io:8080 - grpc://localhost:8080
2022-10-28T09:37:34.257Z - debug: [ServiceEndpoint]: waitForReady - promise running org2peer-api.127-0-0-1.nip.io:8080 - grpc://localhost:8080
2022-10-28T09:37:34.257Z - debug: [DiscoveryHandler]: _execute_endorsements - start
2022-10-28T09:37:34.257Z - debug: [ServiceEndpoint]: waitForReady - Successfully connected to remote gRPC server org2peer-api.127-0-0-1.nip.io:8080 url:grpc://localhost:8080
2022-10-28T09:37:34.257Z - debug: [ServiceEndpoint]: checkConnection[Endorser-org2peer-api.127-0-0-1.nip.io:8080] - end - connected:true
2022-10-28T09:37:34.257Z - debug: [Endorser]: sendProposal[org2peer-api.127-0-0-1.nip.io:8080] - start -- org2peer-api.127-0-0-1.nip.io:8080 grpc://localhost:8080 timeout:60000
2022-10-28T09:37:34.257Z - debug: [Endorser]: sendProposal[org2peer-api.127-0-0-1.nip.io:8080] - running promise
2022-10-28T09:37:34.316Z - debug: [Endorser]: sendProposal[org2peer-api.127-0-0-1.nip.io:8080] - Received proposal response from peer "grpc://localhost:8080": status - 200

## the next lines look a bit odd... as they have swapped from handling org2's peer to org1's peer

2022-10-28T09:37:34.316Z - debug: [DiscoveryHandler]: _build_endorse_group_member >> G0:0 - endorsement completed to org1peer-api.127-0-0-1.nip.io:8080
2022-10-28T09:37:34.316Z - debug: [DiscoveryHandler]: _build_endorse_group_member >> G0:0 - peer org1peer-api.127-0-0-1.nip.io:8080 endorsement will be used
2022-10-28T09:37:34.316Z - debug: [DiscoveryHandler]: _build_endorse_group_member >> G0:0 - returning endorsement
2022-10-28T09:37:34.316Z - debug: [DiscoveryHandler]: _execute_endorsements - endorsement is complete
2022-10-28T09:37:34.316Z - debug: [DiscoveryHandler]: compareProposalResponseResults[undefined] - start
2022-10-28T09:37:34.316Z - debug: [DiscoveryHandler]: _endorse - layout plan 0 completed successfully
2022-10-28T09:37:34.316Z - debug: [Proposal]: send[yourmarbles] - have results from handler
2022-10-28T09:37:34.316Z - debug: [Proposal]: send[yourmarbles] - result is endorsed
2022-10-28T09:37:34.316Z - debug: [Proposal]: getTransactionId[yourmarbles] - start
2022-10-28T09:37:34.316Z - debug: [Channel]: getEndorsers[yourchannel] - start
2022-10-28T09:37:34.316Z - debug: [Channel]: _getServiceEndpoints - start - Org1MSP
2022-10-28T09:37:34.316Z - debug: [Channel]: _getServiceEndpoints - Endorser mspid not matched, not added org2peer-api.127-0-0-1.nip.io:8080 - Org2MSP
2022-10-28T09:37:34.317Z - error: [TransactionEventStrategy]: constructor: No peers for strategy


@mbwhite
Copy link
Contributor Author

mbwhite commented Oct 28, 2022

Working Theory.... microfab has a bit of 'odd' networking to route all the connections though a single port. So all connections effectively are going to localhost:8080 but then routed to the appropriate process.

In the extra above, there's a swap from org2 to org1... in the code this shouldn't change - but there's the getPeer call - this is searching an array matching on the endpoint

The order of the list of the endpoints varies, whether org1 or org2 comes first. Each one, though has it has a different name as seen in the trace, has the same endpoint grpc://localhost:8080. So the first entry in the array matches, irrespective of the actual name. If the array's order happens to be such that the correct answer is found great, otherwise the wrong peer is selected.

The service endpoint can connected ok - so that's got the correct URL...

@mbwhite
Copy link
Contributor Author

mbwhite commented Oct 28, 2022

Scratch all of the above.... the reason local host was being used at all - was because the asLocalhost option was being set.

@mbwhite mbwhite closed this as completed Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant