From caa0fecdc98e7d1dd7e5c7efb15b86fc2659a80d Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 18 Aug 2024 15:23:45 +0100 Subject: [PATCH] relax websocket rate limits * the frontend opens 2 websockets at startup (I'm not completely clear why), and that `minInterval:1sec` was breaking the second connection * as the comment says, "catching up" generates many noteSubscribe messages --- .../backend/src/server/api/StreamingApiServerService.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/StreamingApiServerService.ts b/packages/backend/src/server/api/StreamingApiServerService.ts index 2070ab6106..a2dafb2ebd 100644 --- a/packages/backend/src/server/api/StreamingApiServerService.ts +++ b/packages/backend/src/server/api/StreamingApiServerService.ts @@ -100,7 +100,6 @@ export class StreamingApiServerService { key: 'wsconnect', duration: ms('5min'), max: 32, - minInterval: ms('1sec'), })) { socket.write('HTTP/1.1 429 Rate Limit Exceeded\r\n\r\n'); socket.destroy(); @@ -145,10 +144,14 @@ export class StreamingApiServerService { } const rateLimiter = () => { + // rather high limit, because when catching up at the top of a + // timeline, the frontend may render many many notes, each of + // which causes a message via `useNoteCapture` to ask for + // realtime updates of that note return this.rateLimitThis(user, requestIp, { key: 'wsmessage', - duration: ms('5sec'), - max: 256, + duration: ms('2sec'), + max: 4090, }); };