From f1504a7404fd33b8ba025e8df0f2805e706dc18b Mon Sep 17 00:00:00 2001 From: wphan Date: Fri, 24 Nov 2023 14:20:58 -0800 Subject: [PATCH] increase keepAliveTimeout --- src/index.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8ff170f..0a8c235 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,6 @@ import { DriftClient, initialize, DriftEnv, - SlotSubscriber, UserMap, DLOBOrder, DLOBOrders, @@ -104,6 +103,13 @@ app.use((req, _res, next) => { app.use(errorHandler); const server = http.createServer(app); +// Default keepalive is 5s, since the AWS ALB timeout is 60 seconds, clients +// sometimes get 502s. +// https://shuheikagawa.com/blog/2019/04/25/keep-alive-timeout/ +// https://stackoverflow.com/a/68922692 +server.keepAliveTimeout = 61 * 1000; +server.headersTimeout = 65 * 1000; + const opts = program.opts(); setLogLevel(opts.debug ? 'debug' : 'info'); @@ -212,11 +218,7 @@ const main = async () => { await userMap.subscribe(); const userStatsMap = new UserStatsMap(driftClient, { type: 'polling', - accountLoader: new BulkAccountLoader( - connection, - stateCommitment, - 0 - ), + accountLoader: new BulkAccountLoader(connection, stateCommitment, 0), }); await userStatsMap.subscribe();