socketio / socket.io-admin-ui

Admin UI for Socket.IO
https://admin.socket.io
MIT License
358 stars 95 forks source link

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

Open chohoo89 opened 1 year ago

chohoo89 commented 1 year ago

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"
  },
darrachequesne commented 1 year ago

@chohoo89 did you find a solution?

Note: We should totally catch the rejected promise here.

seolhw commented 1 year ago

我也有一样的问题

sscots commented 1 year ago

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