How to use the grpc.keepalive_time_ms function in grpc

To help you get started, we’ve selected a few grpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-chaincode-node / test / unit / handler.js View on Github external
'grpc.max_send_message_length': 1,
			'grpc.max_receive_message_length': 2,
			'grpc.keepalive_time_ms': 3,
			'grpc.http2.min_time_between_pings_ms': 5,
			'grpc.keepalive_timeout_ms': 8,
			'grpc.http2.max_pings_without_data': 13,
			'grpc.keepalive_permit_without_calls': 21
		});

	t.equal(handler._options['grpc.ssl_target_name_override'], 'dummyHost', 'Test converting opts.ssl-target-name-override to grpc.ssl_target_name_override');
	t.equal(handler._options['grpc.default_authority'], 'dummyHost', 'Test converting opts.ssl-target-name-override to grpc.default_authority');
	t.equal(handler._options['request-timeout'], 12345, 'Test processing request-time option');
	t.equal(handler._options['another-property'], 'dummyValue7', 'Test processing another-property option');
	t.equal(handler._options['grpc.max_send_message_length'], 1, 'Test grpc.max_send_message_length set to 1');
	t.equal(handler._options['grpc.max_receive_message_length'], 2, 'Test grpc.max_receive_message_length set to 2');
	t.equal(handler._options['grpc.keepalive_time_ms'], 3, 'Test grpc.keepalive_time_ms set to 3');
	t.equal(handler._options['grpc.http2.min_time_between_pings_ms'], 5, 'Test grpc.http2.min_time_between_pings_ms set to 5');
	t.equal(handler._options['grpc.keepalive_timeout_ms'], 8, 'Test grpc.keepalive_timeout_ms set to 8');
	t.equal(handler._options['grpc.http2.max_pings_without_data'], 13, 'Test grpc.http2.max_pings_without_data set to 13');
	t.equal(handler._options['grpc.keepalive_permit_without_calls'], 21, 'Test grpc.keepalive_permit_without_calls set to 21');

	// The DNS can be case sensitive in some cases (eg Docker DNS)
	handler = new Handler(chaincodeObj, 'grpc://Peer.Example.com:7051');
	t.equal(handler._endpoint.addr, 'Peer.Example.com:7051', 'Test handler.addr value preserves casing');

	t.end();
});
github hyperledger / fabric-chaincode-node / test / unit / chaincode.js View on Github external
process.argv.push('1234');
	process.argv.push('--grpc.keepalive_timeout_ms');
	process.argv.push('5678');
	process.argv.push('--grpc.http2.min_time_between_pings_ms');
	process.argv.push('7654');
	process.argv.push('--grpc.http2.max_pings_without_data');
	process.argv.push('99');
	process.argv.push('--grpc.keepalive_permit_without_calls');
	process.argv.push('2');
	delete require.cache[require.resolve('fabric-shim/lib/chaincode.js')];
	Chaincode = rewire('fabric-shim/lib/chaincode.js');
	opts = Chaincode.__get__('opts');
	t.deepEqual(opts['peer.address'], 'localhost:7051', 'Test passing only --peer.address argument is correctly picked up');
	t.equal(opts['grpc.max_send_message_length'],101, 'Test grpc.max_send_message_length can be set');
	t.equal(opts['grpc.max_receive_message_length'], 177, 'Test grpc.max_receive_message_length can be set');
	t.equal(opts['grpc.keepalive_time_ms'], 1234, 'Test grpc.keepalive_time_ms can be set');
	t.equal(opts['grpc.http2.min_time_between_pings_ms'], 7654, 'Test grpc.http2.min_time_between_pings_ms can be set');
	t.equal(opts['grpc.keepalive_timeout_ms'], 5678, 'Test grpc.keepalive_timeout_ms can be set');
	t.equal(opts['grpc.http2.max_pings_without_data'], 99, 'Test grpc.http2.max_pings_without_data can be set');
	t.equal(opts['grpc.keepalive_permit_without_calls'], 2, 'Test grpc.keepalive_permit_without_calls can be set');

	// remove the 7 parameters passed
	for (let index = 0; index < 7; index++) {
		process.argv.pop();
		process.argv.pop();
	}

	process.argv.pop();  // remove localhost:7051
	process.argv.pop();  // remove peer.address
	t.end();
});
github maierj / fastlane-action / .github / actions / statistics-chart-action / node_modules / @grpc / grpc-js / build / src / subchannel.js View on Github external
*/
        this.callRefcount = 0;
        /**
         * Tracks channels and subchannel pools with references to this subchannel
         */
        this.refcount = 0;
        // Build user-agent string.
        this.userAgent = [
            options['grpc.primary_user_agent'],
            `grpc-node-js/${clientVersion}`,
            options['grpc.secondary_user_agent'],
        ]
            .filter(e => e)
            .join(' '); // remove falsey values first
        if ('grpc.keepalive_time_ms' in options) {
            this.keepaliveTimeMs = options['grpc.keepalive_time_ms'];
        }
        if ('grpc.keepalive_timeout_ms' in options) {
            this.keepaliveTimeoutMs = options['grpc.keepalive_timeout_ms'];
        }
        this.keepaliveIntervalId = setTimeout(() => { }, 0);
        clearTimeout(this.keepaliveIntervalId);
        this.keepaliveTimeoutId = setTimeout(() => { }, 0);
        clearTimeout(this.keepaliveTimeoutId);
        const backoffOptions = {
            initialDelay: options['grpc.initial_reconnect_backoff_ms'],
            maxDelay: options['grpc.max_reconnect_backoff_ms']
        };
        this.backoffTimeout = new backoff_timeout_1.BackoffTimeout(() => {
            if (this.continueConnecting) {
                this.transitionToState([channel_1.ConnectivityState.TRANSIENT_FAILURE, channel_1.ConnectivityState.CONNECTING], channel_1.ConnectivityState.CONNECTING);
            }
github maierj / fastlane-action / .github / actions / statistics-chart-action / node_modules / @grpc / grpc-js / src / subchannel.ts View on Github external
private channelTarget: string,
    private subchannelAddress: string,
    private options: ChannelOptions,
    private credentials: ChannelCredentials
  ) {
    // Build user-agent string.
    this.userAgent = [
      options['grpc.primary_user_agent'],
      `grpc-node-js/${clientVersion}`,
      options['grpc.secondary_user_agent'],
    ]
      .filter(e => e)
      .join(' '); // remove falsey values first

    if ('grpc.keepalive_time_ms' in options) {
      this.keepaliveTimeMs = options['grpc.keepalive_time_ms']!;
    }
    if ('grpc.keepalive_timeout_ms' in options) {
      this.keepaliveTimeoutMs = options['grpc.keepalive_timeout_ms']!;
    }
    this.keepaliveIntervalId = setTimeout(() => {}, 0);
    clearTimeout(this.keepaliveIntervalId);
    this.keepaliveTimeoutId = setTimeout(() => {}, 0);
    clearTimeout(this.keepaliveTimeoutId);
    const backoffOptions: BackoffOptions = {
      initialDelay: options['grpc.initial_reconnect_backoff_ms'],
      maxDelay: options['grpc.max_reconnect_backoff_ms']
    };
    this.backoffTimeout = new BackoffTimeout(() => {
      if (this.continueConnecting) {
        this.transitionToState(
          [ConnectivityState.TRANSIENT_FAILURE, ConnectivityState.CONNECTING],
github grpc / grpc-node / packages / grpc-js / src / subchannel.ts View on Github external
this.session.on('close', () => {
      this.stopKeepalivePings();
      this.emit('close');
    });
    this.session.on('error', () => {
      this.stopKeepalivePings();
      this.emit('close');
    });
    this.session.on('goaway', () => {
      this.stopKeepalivePings();
      this.emit('close');
    });
    this.userAgent = userAgent;

    if (channelArgs['grpc.keepalive_time_ms']) {
      this.keepaliveTimeMs = channelArgs['grpc.keepalive_time_ms']!;
    }
    if (channelArgs['grpc.keepalive_timeout_ms']) {
      this.keepaliveTimeoutMs = channelArgs['grpc.keepalive_timeout_ms']!;
    }
    this.keepaliveIntervalId = setTimeout(() => {}, 0);
    clearTimeout(this.keepaliveIntervalId);
    this.keepaliveTimeoutId = setTimeout(() => {}, 0);
    clearTimeout(this.keepaliveTimeoutId);
  }
github cjihrig / grpc-server-js / lib / server.js View on Github external
constructor (options = {}) {
    if (options === null || typeof options !== 'object') {
      throw new TypeError('options must be an object');
    }

    this[kServer] = null;
    this[kHandlers] = new Map();
    this[kSessions] = new Set();
    this[kStarted] = false;
    this[kOptions] = { ...defaultServerOptions, ...options };
    this[kSessionOptions] = {
      keepaliveTimeMs: this[kOptions]['grpc.keepalive_time_ms'],
      keepaliveTimeoutMs: this[kOptions]['grpc.keepalive_timeout_ms']
    };
  }