hyperledger-fabricgrpchyperledger-fabric-sdk-jshyperledger-fabric-sdk-gohyperldger-fabric-peer

Why does connection profile in Hyperledger Fabric has gRPC URL?


In the client applications (using Node/Go) we provide connection profile to identify the endpoints of endorsers.

There we specify endpoint of peer in terms of grpc://localhost:port but actually gRPC runs on HTTP2 right?

Then does the Fabric SDK convert the endpoint to a HTTP url or is it handled by fabric peer code?

I mean how is grpc endpoint converted to an HTTP one?

Or does the peer expose a grpc endpoint itself? If yes, how?


Solution

  • As suggested by @david_k in comments above, the URL in connection profile is used for extracting the host and port number after identifying whether it is grpc or grpcs (over SSL) call.

    To verify:

    1. Deploy the fabcar sample and install the node modules.
    2. Go to the Endpoint.js file in the fabric-common node module inside the lib directory. Edit the line corresponding to line 44 here.
    3. Go to the first-network directory (the network used by fabcar sample) to edit the connection profile. Replace the grpcs in the peer and orderer URL corresponding to the edit you made to the Endpoint.js file in node modules.
    4. Return back to the javascript directory and fetch the wallet identities.
    5. Modify the invoke.js to read the new connection profile.
    6. Execute it to see that the transaction is submitted successfully.

    Therefore, we can identify that only the host and port are fetched from the URL to be used for making a grpc/grpcs call to the fabric network.