Skip to content

Socket closed unexpectedly after 5 seconds #2855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
batrdn opened this issue Oct 18, 2024 · 2 comments
Open

Socket closed unexpectedly after 5 seconds #2855

batrdn opened this issue Oct 18, 2024 · 2 comments
Labels

Comments

@batrdn
Copy link

batrdn commented Oct 18, 2024

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

@batrdn batrdn added the Bug label Oct 18, 2024
@qq1012827513
Copy link

Same

@yujiniii
Copy link

Same here. Have you solved this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants