Socket closed unexpectedly after 5 seconds

オープン
#2,855 コメント 4 件 リアクション 2 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
node.js, redis, typescript

調査の方向性

packages/client/lib/client/socket.ts、特に #createSocket から調査を始め、報告されている Redis レプリケーションとクライアント設定で、5 秒後に切断される現象を再現してください。初回接続後のタイムアウト処理を追跡し、ソケットを維持するためにサポートされている動作を特定してください。原因と想定される設定またはコードの変更が確定し、回帰チェックでカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Bug
Description

I'm running redis with replication, with the simple client configuration createClient({ url }). After the initial connection is successfully established, the socket is closed after 5 seconds. I guess this is because the socket connectTimeout is by default 5s, and in packages/client/lib/client/socket.ts, it'll close it based on the property.

async #createSocket(): Promise<net.Socket | tls.TLSSocket> {
    const socket = this.#socketFactory.create();

    let onTimeout;
    if (this.#connectTimeout !== undefined) {
      onTimeout = () => socket.destroy(new ConnectionTimeoutError());
      socket.once('timeout', onTimeout);
      socket.setTimeout(this.#connectTimeout);
    }
    ....
    return socket;
  }

I've already taken a look into other related issues, and I tried setting pingInterval and setting socket connectTimeout to 0, and as expected, the socket is closed regardless. What is the recommended way to keep the socket connection alive?

INFO:
Redis is deployed via Helm (bitnami 20.1.4) into kubernetes cluster, with one master node and 3 replicas.

Node.js Version

20.14.0

Redis Server Version

7.4.0

Node Redis Version

4.7.0

Platform

Linux

Logs

No response

主要言語
TypeScript
スター
17.6k
フォーク
2k
平均マージ
1日 22時間
マージ済み PR(30日)
62

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

redis/node-redis のほかの issue

redis/node-redis の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。