Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit a688fc2

Browse files
committed
FABN-912 NodeSDK add connection options
Allow a set of connection options to be common and associated with the client. The client will apply the common set to each new peer and orderer it builds including peers and orderers that it builds for discovery. The user will be allowed to override during create any of the settings. The option set will originate in the system configuration (default.json). Users will be able to override or add new ones at anytime to the client instance. The options may also be kept in the common connection profile client section. Change-Id: I06e27db8835b8453e6289bc1201f8e0d21802912 Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
1 parent 532e9d6 commit a688fc2

File tree

14 files changed

+308
-150
lines changed

14 files changed

+308
-150
lines changed

docs/tutorials/channel-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ event registrations of the shutdown by using the registered `errorCallBack`s.
7878
#### `peer` parameter
7979
This parameter must be included when getting a new instance of the
8080
`ChannelEventHub`. The value may be a `Peer` instance or the name of a peer when
81-
using a `connection profile` see [How to use a common network configuration file](tutorial-network-config.html).
81+
using a `connection profile` see [How to use a common common connection profile file](tutorial-network-config.html).
8282

8383
#### `eventCallback` parameter
8484
This parameter must be included. This is the callback function to be notified

docs/tutorials/discovery.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,10 @@ peers:
355355
```
356356
When a channel is created using the `client.getChannel()` after the client
357357
instance has loaded a connection profile, the fabric-client will create peers
358-
and assign them to the channel. Peers with the the `discover` role will be used
358+
and assign them to the channel.
359+
The peers and orderers will inherent the connection options as assigned to
360+
the client instance. see {@link Client#addConnectionOptions}
361+
Peers with the the `discover` role will be used
359362
when the `channel.initialize()` is called and no peer is passed as a target.
360363

361364
```

docs/tutorials/network-config.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ certificateAuthorities:
144144
caName: caorg2
145145
```
146146

147-
The following example will have an existing fabric client load a connection profile configuration. The definition will only contain client side definitions and no fabric network definitions. Calling for a load on an existing fabric client does an overlay of the top level sections in the file being loaded replacing the sections on those previously loaded. In this case the file being loaded only has a client section, therefore the loaded definition will now have the previously loaded channels, organizations, peers, orderers, and certificateAuthorities section definitions and the newly loaded client section definition. This allows for an existing fabric client to be able to work within different organization. Note: The the SDK's `grpc-max-send-message-length` default is -1 (unlimited).
147+
The following example will have an existing fabric client load a connection profile configuration. The definition will only contain client side definitions and no fabric network definitions. The client may load a new profile at anytime, it will overlay the top level sections it contains of those previously loaded. In this case the file being loaded only has a client section, therefore the loaded definition will now have the previously loaded channels, organizations, peers, orderers, and certificateAuthorities section definitions and the newly loaded client section definition. This allows for an existing fabric client to be able to work within different organization.
148+
Notice this client definition contains a `connection` section with an `options` attribute in the
149+
client section. Settings defined here will be applied to new peer and orderer
150+
instances the client creates.
151+
This will include peers and orderers that will be created automatically when
152+
using the discovery service.
153+
Peers and Orderers may override these connection settings in their `grpcOptions` settings.
154+
155+
Note: The fabric-client `grpc-max-send-message-length` and `grpc-max-receive-message-length` defaults are -1 (unlimited).
148156
```
149157
client.loadFromConfig('test/fixtures/org1.yaml');
150158
```
@@ -159,6 +167,9 @@ client:
159167
path: "/tmp/hfc-kvs/org1"
160168
cryptoStore:
161169
path: "/tmp/hfc-cvs/org1"
170+
connection:
171+
options
172+
grpc.keepalive_time_ms: 120000
162173
```
163174

164175
### Setup the stores
@@ -192,7 +203,7 @@ fabric_ca_client.register({enrollmentID: 'user1', affiliation: 'org1'}, admin)
192203
}).then((user)=> {
193204
```
194205
### Work with mutual TLS
195-
When your network configuration includes mutual TLS, the client certificate and private key must be available to the client instance before the endpoints are automatically built. The client instance will be able to pass the required material to the endpoint instance that is needed to establish the connection. The example shown will also retrieve the material. These steps must be performed before any actions on the fabric network.
206+
When your network is using mutual TLS, the client certificate and private key must be available to the client instance before the endpoints are automatically built. The client instance will be able to pass the required material to the endpoint instance that is needed to establish the connection. The example shown will also retrieve the material. These steps must be performed before any actions on the fabric network.
196207
```
197208
// get the CA associated with this client's organization
198209
let fabric_ca_client = client.getCertificateAuthority();
@@ -221,7 +232,7 @@ Notice in the organizations section of the connection profile configuration that
221232
client.setAdminSigningIdentity('admin privateKey','admin cert');
222233
```
223234

224-
Assume that connection profile configurations have been loaded, setting up both an organization with an admin and indicating that the client is in that organization. Then when the call is made to get a transaction id object, the fabric client will check to see if an admin has been assigned to the fabric client and use that to generate the transaction id. The transaction id returned will be tagged that it was generated with the assigned administrative identity. Notice how the request object being built is using just a name for the orderer rather than a `Orderer` object. The fabric client will look up this name in the loaded connection profile configuration. When the `createChannel` call is made, the fabric client will know that this action should be signed by the administrative identity because the transaction id was marked as an admin based transaction. Note that the administrative signing identity is not required if the logged in user is an administrative user and has been assigned to the fabric client.
235+
Assume that a common connection profile has been loaded, setting up both an organization with an admin and indicating that the client is in that organization. Then when the call is made to get a transaction id object, the fabric client will check to see if an admin has been assigned to the fabric client and use that to generate the transaction id. The transaction id returned will be tagged that it was generated with the assigned administrative identity. Notice how the request object being built is using just a name for the orderer rather than an `Orderer` object. The fabric client will look up this name in the loaded connection profile configuration. When the `createChannel` call is made, the fabric client will know that this action should be signed by the administrative identity because the transaction id was marked as an admin based transaction. Note that the administrative signing identity is not required if the logged in user is an administrative user and has been assigned to the fabric client.
225236
```
226237
let tx_id = client.newTransactionID(true);
227238

fabric-client/config/default.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@
1717
"certificate-authority-client": "fabric-ca-client",
1818
"nonce-size" : 24,
1919
"grpc-ssl-cipher-suites": "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384",
20-
"grpc.max_receive_message_length": -1,
21-
"grpc.max_send_message_length": -1,
20+
"connection-options": {
21+
"grpc.max_receive_message_length": -1,
22+
"grpc.max_send_message_length": -1,
23+
"grpc.keepalive_time_ms": 120000,
24+
"grpc.http2.min_time_between_pings_ms": 120000,
25+
"grpc.keepalive_timeout_ms": 20000,
26+
"grpc.http2.max_pings_without_data": 0,
27+
"grpc.keepalive_permit_without_calls": 1
28+
},
2229
"network-config-schema" : {
2330
"1.0": "./impl/NetworkConfig_1_0.js"
2431
},

fabric-client/lib/Channel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ const Channel = class {
22572257
* added to the channel object.
22582258
* @param {boolean} useAdmin - Optional. Indicates that the admin credentials
22592259
* should be used in making this call to the peer. An administrative
2260-
* identity must have been loaded by network configuration or by
2260+
* identity must have been loaded by common connection profile or by
22612261
* using the 'setAdminSigningIdentity' method.
22622262
* @returns {Promise} A Promise for a fully decoded {@link ChaincodeQueryResponse} object.
22632263
*/
@@ -3383,7 +3383,7 @@ const Channel = class {
33833383
_getTargetForQuery(target) {
33843384
if (Array.isArray(target)) {
33853385
throw new Error('"target" parameter is an array, but should be a singular peer object' +
3386-
' ' + 'or peer name according to the network configuration loaded by the client instance');
3386+
' ' + 'or peer name according to the common connection profile loaded by the client instance');
33873387
}
33883388

33893389
const targets = this._getTargets(target, Constants.NetworkConfig.LEDGER_QUERY_ROLE, true);

0 commit comments

Comments
 (0)