grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

How do I set options in grpc from firebase?

Open hfossli-agens opened this issue 2 years ago • 2 comments

This is related to https://github.com/grpc/grpc-node/issues/1769#issuecomment-902053418.

I want to set options like grpc.keepalive_time_ms, grpc.keepalive_timeout_ms and grpc.keepalive_permit_without_calls. How do I set them?

Is this the way?

GRPC_ARG_KEEPALIVE_TIME_MS=10000
GRPC_ARG_KEEPALIVE_TIMEOUT_MS=10000

Or can I do this?

const grpc = require("@grpc/grpc-js")
grpc.keepalive_time_ms = 10000;

I don't understand from the documentation how I can augment grpc to behave as wanted when using the firebase-admin sdk.

hfossli-agens avatar May 25 '22 07:05 hfossli-agens

3rd parameter to the client under options attribute. Like this:

const DEFAULT_OPTIONS = {
    'grpc.max_connection_age_grace_ms': DEFAULT_DEADLINE + GRACE_PERIOD_MARGIN ,
    'grpc.dns_min_time_between_resolutions_ms': DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS,
    ....
};

const defaultConfig = {
   ....
   options: DEFAULT_OPTIONS,
};
const Client = grpc.makeGenericClientConstructor({});
const client = new Client(address, defaultConfig.credentials, defaultConfig.options);

jorge07 avatar May 25 '22 08:05 jorge07

Thanks @jorge07. Does this work in my case? I am not creating the client for firebase-admin so how do I make sure firebase-admin uses this grpc client?

hfossli-agens avatar May 25 '22 09:05 hfossli-agens

This question should be addressed to the firebase-admin repository. They can tell you how to use their APIs to pass options to grpc-js.

murgatroid99 avatar Dec 14 '23 21:12 murgatroid99