summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/StreamingApiServerService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-06-13 16:46:01 +0900
committerGitHub <noreply@github.com>2023-06-13 16:46:01 +0900
commit7093662ce5c17a8096c33712d0056de9fd4b5a41 (patch)
treea89436b3c3b474a1b1c985876d9e769ea1ac9f9e /packages/backend/src/server/api/StreamingApiServerService.ts
parentMerge pull request #10961 from misskey-dev/develop (diff)
parentユーザー統計表示機能を削除 (diff)
downloadmisskey-7093662ce5c17a8096c33712d0056de9fd4b5a41.tar.gz
misskey-7093662ce5c17a8096c33712d0056de9fd4b5a41.tar.bz2
misskey-7093662ce5c17a8096c33712d0056de9fd4b5a41.zip
Merge pull request #10990 from misskey-dev/develop
Release: 13.13.2
Diffstat (limited to 'packages/backend/src/server/api/StreamingApiServerService.ts')
-rw-r--r--packages/backend/src/server/api/StreamingApiServerService.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/packages/backend/src/server/api/StreamingApiServerService.ts b/packages/backend/src/server/api/StreamingApiServerService.ts
index 893dfe956e..d1394d6d76 100644
--- a/packages/backend/src/server/api/StreamingApiServerService.ts
+++ b/packages/backend/src/server/api/StreamingApiServerService.ts
@@ -128,26 +128,27 @@ export class StreamingApiServerService {
ev.removeAllListeners();
stream.dispose();
this.redisForSub.off('message', onRedisMessage);
+ this.#connections.delete(connection);
if (userUpdateIntervalId) clearInterval(userUpdateIntervalId);
});
- connection.on('message', async (data) => {
+ connection.on('pong', () => {
this.#connections.set(connection, Date.now());
- if (data.toString() === 'ping') {
- connection.send('pong');
- }
});
});
+ // 一定期間通信が無いコネクションは実際には切断されている可能性があるため定期的にterminateする
this.#cleanConnectionsIntervalId = setInterval(() => {
const now = Date.now();
for (const [connection, lastActive] of this.#connections.entries()) {
- if (now - lastActive > 1000 * 60 * 5) {
+ if (now - lastActive > 1000 * 60 * 2) {
connection.terminate();
this.#connections.delete(connection);
+ } else {
+ connection.ping();
}
}
- }, 1000 * 60 * 5);
+ }, 1000 * 60);
}
@bindThis