peer discovery/collection errors when calling chaincode from nodejs client


Simeon MacMillen
 

Hello Fabric community,

I am encountering a couple issues when accessing/writing data to a Fabric (2.3) network from a Node.js client.  I have a 4-org network running on 4 different VPS instances.  (Each VPS hosts 1 org with dockerized peer and orderer instances.  The VPSs are linked via a Docker swarm overlay network.)  There are 2 shared private data collections, one with 3 orgs, 1 with 2 orgs.  (Only 1 org is a member of both collections.)

When I start my node client (on any of the VPS instances), I get error messages like these:

2021-03-25T10:48:10.616Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.orgb.scm.com:7051, url:grpcs://localhost:7051, connected:false, connectAttempted:true
2021-03-25T10:48:10.617Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.orgb.scm.com:7051 url:grpcs://localhost:7051 timeout:3000
2021-03-25T10:48:10.618Z - error: [DiscoveryService]: _buildPeer[scm1] - Unable to connect to the discovered peer peer0.orgb.scm.com:7051 due to Error: Failed to connect before the deadline on Endorser- name: peer0.orgb.scm.com:7051, url:grpcs://localhost:7051, connected:false, connectAttempted:true

It seems that the client org is having trouble connecting with the other orgs outside of Docker.  Note that "asLocalhost" is set to true.

However, after displaying the error messages, I can use the client to successfully read and write to the ledger.  So it seems the error messages are more of a cosmetic issue than a functional issue?  (They certainly would not inspire confidence in a demo!)  The error messages also occur randomly after other read/write requests.


To deal with this problem, I tried dockerizing my node client.  This way, the client could use the same docker overlay network and natively resolve the other hosts.  This worked great (I thought) - no more errors on startup or queries!  However, when I try to write data to the ledger, I get this error:

--> Submit Transaction: AddPart A2
2021-03-24T23:18:55.339Z - error: [Transaction]: Error: No valid responses from any peers. Errors:
    peer=peer0.orga.scm.com:7051, status=500, message=AddPart cannot be performed: Error client from org ORGBMSP is not authorized to read or write private data from an org ORGAMSP peer
Error detected when calling addPart function:Error: No valid responses from any peers. Errors:
    peer=peer0.orga.scm.com:7051, status=500, message=AddPart cannot be performed: Error client from org ORGBMSP is not authorized to read or write private data from an org ORGAMSP peer

So I solved the discovery problem, but now the client is connecting to any organization peer it wants to?  I could avoid calling the verifyClientOrgMatchesPeerOrg function in the Chaincode, but that would potentially introduce other problems.

Is there a way to force the client to only use the client org's peer?  Or is there a better approach here?

Sincerely,
Simeon MacMillen


Join fabric@lists.hyperledger.org to automatically receive all group messages.