2

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?

Chintan Rajvir
  • 689
  • 6
  • 20

2 Answers2

1

For communicating between the front-end and the Hyperledger Fabric Layer, we have two ways, one to use the gRPC calls OR use one of the SDKs provided by the Hyperledger Community. There are no REST API calls after v1.0, as opposed to v0.6, which had REST API calls, where you could use the IP Addresses to fire transactions to the Orderer, then Consensus.

Making it limited to gRPC and SDKs improves the design and connection security issues, which is vital for the Blockchain to work. gRPC is the HTTPS 2.0 protocol for communication which is faster and has improved security features over HTTPS 1.1. SDKs use gRPC calls to communicate to the network. So, putting it plainly, if you need to communicate with the Network, you need to use gRPC calls only

  • Understood! So if I am not wrong, does this mean that the SDKs read the connection profile, the gRPC URL of peer, and converts it to a HTTP URL (as a gRPC call to the peer)? – Chintan Rajvir Mar 13 '20 at 09:12
  • grpc by default is http 2. It does not convert into the https previous version 1.1. Hence there is no conversion – Noushad Mohamed Mar 13 '20 at 09:16
  • Sorry! That I know of! I mean to say that the connection profile has peer address something like this: grpcs://localhost:7051 but if I am not wrong, there is nothing like "grpcs" right? So the SDK must parse the URL and make HTTP2 call to the peer like: "https://localhost:7051" .. Please correct me if I am wrong! – Chintan Rajvir Mar 13 '20 at 09:20
  • The sdk doesn't convert it to http2, rather it extracts the host and port from the url, checking to see if to use ssl or not grpcs vs grpc then uses the node grpc apis to establish the appropriate connection (which will use http2 under the covers). So technically the `grpc` protocol name is special to the connection profile for client sdk applications – david_k Mar 13 '20 at 12:10
  • Perfect thats what I expected! Thanks! – Chintan Rajvir Mar 13 '20 at 14:10
0

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.

Chintan Rajvir
  • 689
  • 6
  • 20