Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
Merge pull request #214 from xmtp/nm/add-grpc-timeouts
Browse files Browse the repository at this point in the history
Add GRPC keepalives back
  • Loading branch information
neekolas authored May 2, 2024
2 parents b5389e1 + fb2a9cd commit d565b7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-walls-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@xmtp/grpc-api-client": patch
---

Adjust GRPC keepalive settings
16 changes: 10 additions & 6 deletions packages/grpc-api-client/src/GrpcApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,21 @@ 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",
}

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
Expand All @@ -58,10 +65,7 @@ export default class GrpcApiClient implements ApiClient {
this.grpcClient = new MessageApiClient(
new GrpcTransport({
host: apiUrl,
clientOptions: {
"grpc.keepalive_time_ms": 1000 * 60 * 5, // 5 minutes
"grpc.enable_retries": 1,
},
clientOptions,
channelCredentials: isSecure
? credentials.createSsl()
: credentials.createInsecure(),
Expand Down

0 comments on commit d565b7e

Please sign in to comment.