From 1fec662d3ee56d0c79894e9c6a6f0a83a487d1c8 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 2 May 2024 13:22:20 -0700 Subject: [PATCH 1/4] Revert "Merge pull request #212 from xmtp/revert-204-nm/grpc-timeout-options" This reverts commit 117d5a62666bb0653e92978e69311d868a9a569e, reversing changes made to fd61602449fefa5d46b99ca8a82a4c95399ad334. --- packages/grpc-api-client/src/GrpcApiClient.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/grpc-api-client/src/GrpcApiClient.ts b/packages/grpc-api-client/src/GrpcApiClient.ts index 5121af3..a1ac6fb 100644 --- a/packages/grpc-api-client/src/GrpcApiClient.ts +++ b/packages/grpc-api-client/src/GrpcApiClient.ts @@ -36,8 +36,8 @@ import { } from "./gen/message_api/v1/message_api.js" const API_URLS: { [k: string]: string } = { - dev: "dev.xmtp.network:5556", - production: "production.xmtp.network:5556", + dev: "grpc.dev.xmtp.network:443", + production: "grpc.production.xmtp.network:443", local: "localhost:5556", } @@ -55,13 +55,16 @@ export default class GrpcApiClient implements ApiClient { this.apiUrl = apiUrl this.appVersion = appVersion this.logger = pino({ name: "GrpcApiClient" }) + const grpcOptions = { + "grpc.keepalive_timeout_ms": 1000 * 10, // 10 seconds + "grpc.keepalive_time_ms": 1000 * 15, // 15 seconds + "grpc.enable_retries": 1, + "grpc.keepalive_permit_without_calls": 1, + } this.grpcClient = new MessageApiClient( new GrpcTransport({ host: apiUrl, - clientOptions: { - "grpc.keepalive_time_ms": 1000 * 60 * 5, // 5 minutes - "grpc.enable_retries": 1, - }, + clientOptions: grpcOptions, channelCredentials: isSecure ? credentials.createSsl() : credentials.createInsecure(), From c249e1284bba9f2adb6da4a404e8eca0b65c5b34 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 2 May 2024 13:48:58 -0700 Subject: [PATCH 2/4] Change to 30 seconds --- packages/grpc-api-client/src/GrpcApiClient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/grpc-api-client/src/GrpcApiClient.ts b/packages/grpc-api-client/src/GrpcApiClient.ts index a1ac6fb..586d782 100644 --- a/packages/grpc-api-client/src/GrpcApiClient.ts +++ b/packages/grpc-api-client/src/GrpcApiClient.ts @@ -57,9 +57,9 @@ export default class GrpcApiClient implements ApiClient { this.logger = pino({ name: "GrpcApiClient" }) const grpcOptions = { "grpc.keepalive_timeout_ms": 1000 * 10, // 10 seconds - "grpc.keepalive_time_ms": 1000 * 15, // 15 seconds + "grpc.keepalive_time_ms": 1000 * 30, // 30 seconds "grpc.enable_retries": 1, - "grpc.keepalive_permit_without_calls": 1, + "grpc.keepalive_permit_without_calls": 0, } this.grpcClient = new MessageApiClient( new GrpcTransport({ From a4809e5e8db034f88f04136a6568251e9e41d380 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 2 May 2024 14:17:39 -0700 Subject: [PATCH 3/4] Move options out of function --- packages/grpc-api-client/src/GrpcApiClient.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/grpc-api-client/src/GrpcApiClient.ts b/packages/grpc-api-client/src/GrpcApiClient.ts index 586d782..51bc373 100644 --- a/packages/grpc-api-client/src/GrpcApiClient.ts +++ b/packages/grpc-api-client/src/GrpcApiClient.ts @@ -44,6 +44,13 @@ const API_URLS: { [k: string]: string } = { const SLEEP_TIME = 1000 const MAX_RETRIES = 4 +const clientOptions = { + "grpc.keepalive_timeout_ms": 1000 * 10, // 10 seconds + "grpc.keepalive_time_ms": 1000 * 30, // 30 seconds + "grpc.enable_retries": 1, + "grpc.keepalive_permit_without_calls": 0, +} as const + export default class GrpcApiClient implements ApiClient { grpcClient: MessageApiClient private authCache?: AuthCache @@ -55,16 +62,10 @@ export default class GrpcApiClient implements ApiClient { this.apiUrl = apiUrl this.appVersion = appVersion this.logger = pino({ name: "GrpcApiClient" }) - const grpcOptions = { - "grpc.keepalive_timeout_ms": 1000 * 10, // 10 seconds - "grpc.keepalive_time_ms": 1000 * 30, // 30 seconds - "grpc.enable_retries": 1, - "grpc.keepalive_permit_without_calls": 0, - } this.grpcClient = new MessageApiClient( new GrpcTransport({ host: apiUrl, - clientOptions: grpcOptions, + clientOptions, channelCredentials: isSecure ? credentials.createSsl() : credentials.createInsecure(), From fb2a9cde0921d15d2f85fb9f6031d881ab5c67b7 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 2 May 2024 14:18:22 -0700 Subject: [PATCH 4/4] docs(changeset): Adjust GRPC keepalive settings --- .changeset/weak-walls-cover.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/weak-walls-cover.md diff --git a/.changeset/weak-walls-cover.md b/.changeset/weak-walls-cover.md new file mode 100644 index 0000000..a9a626b --- /dev/null +++ b/.changeset/weak-walls-cover.md @@ -0,0 +1,5 @@ +--- +"@xmtp/grpc-api-client": patch +--- + +Adjust GRPC keepalive settings