Socket.IO stops working randomly until page refresh

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

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

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

評価

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

調査の方向性

提供された TypeScript フロントエンド接続設定とバックエンドの起動設定から始め、namespace、再接続、Redis の動作を観察しながらランダムな切断を再現します。再現可能な原因を特定し、範囲を限定した fix または診断結果を文書化できれば完了です。この issue では repository のファイルやテストは指定されていません。

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

説明

needs investigation

Hi, I'm using Socket.IO in a Node.js project, and sometimes the socket connection just stops working. The only way to get it working again is by refreshing the browser page.

I'm using namespaces to separate tenants, and Redis to manage socket IDs. Here is my frontend and backend configuration:

Frontend (Client-side):

export function connectSocketToNamespace(namespace: string): void {
    socket = io(`${import.meta.env.VITE_SERVER_URL}/${namespace}`, {
        auth: {
            token: getAuthToken()
        },
        query: {
            sessionKey: getSession()
        },
        transports: ["websocket"],
        upgrade: false,
        reconnection: true,
        reconnectionAttempts: Infinity,
        reconnectionDelay: 2000,
        reconnectionDelayMax: 10000,
        randomizationFactor: 0.5,
    });
}

Backend (Server-side - AdonisJS):

public boot() {
    if (!this.booted) {
        this.io = new Server(AdonisServer.instance!, {
            maxHttpBufferSize: maxUploadFileSize(),
            pingInterval: 10000,
            pingTimeout: 25000,
            cors: {
                origin: Env.get('CLIENT_URL')
            }
        });

        this.booted = true;

        this.configureNamespaces();
        this.clearOldSockets();
    }
}

There are no errors in the console or server logs, and this issue happens randomly.

Has anyone experienced something similar? Could this be related to the Redis adapter or the namespace handling? Any suggestions on debugging or fixing this issue?

Thanks in advance!

主要言語
TypeScript
スター
63.2k
フォーク
10.2k
平均マージ
6日 4時間
マージ済み PR(30日)
6

環境構築

はじめの一歩

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

socketio/socket.io のほかの issue

socketio/socket.io の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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