Skip to content

Commit

Permalink
[FAB-5117] NodeSDK - grpc dflt send/receive size
Browse files Browse the repository at this point in the history
Setting the grpc settings for send and recieve size
to -1 for unlimited. The users may override this
setting but should not have a need. The fabric channel
will control the sizes size.

Change-Id: I0e2efa4f79099cd46dcfc8379b0f1203be589f46
Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
  • Loading branch information
harrisob committed Nov 8, 2017
1 parent 47f63a8 commit 1815caf
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
4 changes: 2 additions & 2 deletions fabric-client/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"certificate-authority-client": "fabric-ca-client",
"nonce-size" : 24,
"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",
"grpc-max-receive-message-length": 0,
"grpc-max-send-message-length": 0,
"grpc.max_receive_message_length": -1,
"grpc.max_send_message_length": -1,
"network-config-schema" : {
"1.0": "./impl/NetworkConfig_1_0.js"
}
Expand Down
4 changes: 2 additions & 2 deletions fabric-client/lib/Orderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ var Orderer = class extends Remote {
});

broadcast.on('error', function (err) {
clearTimeout(broadcast_timeout);
broadcast.end();
if(err && err.code) {
if(err.code == 14) {
clearTimeout(broadcast_timeout);
logger.error('sendBroadcast - on error: %j',err.stack ? err.stack : err);
return reject(new Error('SERVICE_UNAVAILABLE'));
}
Expand Down Expand Up @@ -251,8 +251,8 @@ var Orderer = class extends Remote {

deliver.on('error', function (err) {
logger.debug('sendDeliver - on error');
clearTimeout(deliver_timeout);
if(connect) {
clearTimeout(deliver_timeout);
deliver.end();
connect = false;
if(err && err.code) {
Expand Down
11 changes: 4 additions & 7 deletions fabric-client/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,23 +474,20 @@ module.exports.newCryptoKeyStore = function(KVSImplClass, opts) {
};

/*
* This function will create a new key value pair type options object based
* This function will create a new key value pair type options list based
* on the one passed in. The option setting will be added to the options if it
* does not exist in the options already. The value of the new setting will be the default
* value passed in unless there is a value in the config settings
* does not exist in the options already. The value of the setting being checked
* will be the default value passed in unless there is a value in the config
* settings or already on the options list.
*/
module.exports.checkAndAddConfigSetting = function(option_name, default_value, options) {
var return_options = {};
return_options[option_name] = module.exports.getConfigSetting(option_name, default_value);
var found_option = false;
if(options) {
var keys = Object.keys(options);
for(var i in keys) {
let key = keys[i];
var value = options[key];
if(key === option_name) {
found_option = true;
}
return_options[key] = value;
}
}
Expand Down
44 changes: 40 additions & 4 deletions test/integration/e2e/create-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ test('\n\n***** SDK Built config update create flow *****\n\n', function(t) {
}
);

var orderer_bad = client.newOrderer(
ORGS.orderer.url,
{
'pem': caroots,
'ssl-target-name-override': ORGS.orderer['server-hostname'],
'grpc.max_send_message_length': 6800
}
);


var TWO_ORG_MEMBERS_AND_ADMIN = [{
role: {
Expand Down Expand Up @@ -183,6 +192,35 @@ test('\n\n***** SDK Built config update create flow *****\n\n', function(t) {

logger.debug('\n***\n done signing \n***\n');

// build up a create request to include
// an orderer that will fail
let tx_id = client.newTransactionID();
var request = {
config: config,
signatures : signatures,
name : channel_name,
orderer : orderer_bad,
txId : tx_id
};

// send create request to bad orderer
return client.createChannel(request);
}).then((result) => {
logger.debug('\n***\n completed the create \n***\n');

logger.debug(' response ::%j',result);
t.fail('Failed when this Successfully created the channel.');
t.end();
throw new Error('Failed to get max send error');
}, (err) => {
if(err.toString().indexOf('Sent message larger than max') > -1) {
t.pass('Successfully failed with max error on the create channel: ' + err.toString());
} else {
t.fail('Failed to fail with max error on the create channel: ' + err.stack ? err.stack : err);
}

return true;
}).then((nothing) => {
// build up the create request
let tx_id = client.newTransactionID();
var request = {
Expand All @@ -195,8 +233,7 @@ test('\n\n***** SDK Built config update create flow *****\n\n', function(t) {

// send create request to orderer
return client.createChannel(request);
})
.then((result) => {
}).then((result) => {
logger.debug('\n***\n completed the create \n***\n');

logger.debug(' response ::%j',result);
Expand All @@ -210,8 +247,7 @@ test('\n\n***** SDK Built config update create flow *****\n\n', function(t) {
}, (err) => {
t.fail('Failed to create the channel: ' + err.stack ? err.stack : err);
t.end();
})
.then((nothing) => {
}).then((nothing) => {
t.pass('Successfully waited to make sure new channel was created.');
t.end();
}, (err) => {
Expand Down

0 comments on commit 1815caf

Please sign in to comment.