Skip to content
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

Redis-adapter -> reject(new Error("timeout reached while waiting for fetchSockets response")) #60

Open
chohoo89 opened this issue Jan 18, 2023 · 3 comments

Comments

@chohoo89
Copy link

chohoo89 commented Jan 18, 2023

hello.

I am configuring a socket.io server using pm2 and redis-adapter.
I'm using express to bring up the admin ui on the same port as socket.io.

public async connect(http_server: http.Server): Promise<void> {
    try {
      SocketIO.server = new Server({
        cors: {
          origin: "*",
          credentials: true
        },
        transports: ['websocket'],
        allowUpgrades: true,
      });
      const pubClient = createClient({
        socket: {
          host: process.env.REDIS_IP,
          port: <number><unknown>process.env.REDIS_PORT,
        },
        password: process.env.REDIS_PASSWORD
      });
      const subClient = pubClient.duplicate();
      await pubClient.connect();
      await subClient.connect();
      SocketIO.server.adapter(createAdapter(pubClient, subClient));
      SocketIO.server.attach(http_server);

      instrument(SocketIO.server, {
        auth: {
          type: "basic",
          username: "...",
          password: "^__^", 
        },
        mode: "development",
        serverId: `${hostname()}#${process.pid}`,
      });

    } catch (err) {

      process.exit(1);
    } 
  }

run it like this, it works without any problems, but when you connect to http://localhost:3900, the following message occurs after about 3 to 5 seconds.

D:\Project\socket\node_modules\@socket.io\redis-adapter\dist\index.js:615
                    reject(new Error("timeout reached while waiting for fetchSockets response"));
                           ^
Error: timeout reached while waiting for fetchSockets response
    at Timeout._onTimeout (D:\Project\socket\node_modules\@socket.io\redis-adapter\dist\index.js:615:28)
    at listOnTimeout (node:internal/timers:564:17)
    at processTimers (node:internal/timers:507:7)

https://admin.socket.io <- this url is Same.. the server crashes.

What's the problem? 😢

npm version

"dependencies": {
    "@socket.io/admin-ui": "^0.5.1",
    "@socket.io/redis-adapter": "^8.0.1",
    "express": "^4.18.2",
    "redis": "^4.0.4",
    "socket.io": "^4.5.4"
  },
@chohoo89 chohoo89 reopened this Jan 18, 2023
@darrachequesne
Copy link
Member

@chohoo89 did you find a solution?

Note: We should totally catch the rejected promise here.

@seolhw
Copy link

seolhw commented Apr 21, 2023

我也有一样的问题

@sscots
Copy link

sscots commented May 26, 2023

I'm having the same issue but I'm actually calling fetchSockets() in my instance.
What reasons would the fetchSockets ever timeout for?

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

No branches or pull requests

4 participants