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

TypeError: this.subClient.psubscribe is not a function #411

Closed
yudao opened this issue Jun 14, 2021 · 5 comments
Closed

TypeError: this.subClient.psubscribe is not a function #411

yudao opened this issue Jun 14, 2021 · 5 comments

Comments

@yudao
Copy link

yudao commented Jun 14, 2021

Hi,

We've just upgraded redis adapter and ioredis to the latest version:

"@socket.io/redis-adapter": "^7.0.0",
"ioredis": "^4.27.6",

We using RedisAdapter extended:

module.exports = class OurOwnRedisAdapter extends RedisAdapter {
  constructor(nsp) {
    const options = Object.assign({
      pubClient,
      subClient: pubClient.duplicate(),
      requestsTimeout: 1000
    }, config.websocket.adapter);
    super(nsp, null, options);
  }
 ...
}

Our pubClient is created like this:

const pubClient = new Redis(_.merge(
    {
      dropBufferSupport: true // see https://github.com/luin/ioredis/wiki/Improve-Performance#dropbuffersupport-option
    },
    config.redis,
    scopedConfig,
    options,
    reconnectOnError,
  ));

And now we get this error that is difficult to know why.

 uncaughtException {
      error: TypeError: this.subClient.psubscribe is not a function
          at new RedisAdapter (/node_modules/@socket.io/redis-adapter/dist/index.js:64:24)
          at new OurOwnRedisAdapter (/lib/websocket-adapter.js:39:5)
          at Namespace._initAdapter (/node_modules/socket.io/dist/namespace.js:40:24)
          at Server.adapter (/node_modules/socket.io/dist/index.js:133:17)
          at module.exports (/lib/websocket.js:27:6)
          at Server.<anonymous> (/server.js:25:16)
          at Object.onceWrapper (events.js:421:28)
          at Server.emit (events.js:315:20)
          at emitListeningNT (net.js:1352:10)
          at processTicksAndRejections (internal/process/task_queues.js:79:21)
    }
@apydo
Copy link

apydo commented Jul 7, 2021

No idea what happens here ?

@darrachequesne
Copy link
Member

Since version 7.0.0, the pubClient and subClient option must be passed in the list of arguments, and not in the options anymore:

const pubClient = createClient({ host: "localhost", port: 6379 });
const subClient = pubClient.duplicate();

io.adapter(redisAdapter(pubClient, subClient));

Which in your case should give:

module.exports = class OurOwnRedisAdapter extends RedisAdapter {
  constructor(nsp) {
    const subClient = pubClient.duplicate();
    const options = Object.assign({
      requestsTimeout: 1000
    }, config.websocket.adapter);
    super(nsp, pubClient, subClient, options);
  }
 ...
}

@Morbden
Copy link

Morbden commented Nov 25, 2021

Hi,

We've just upgraded redis adapter and ioredis to the latest version:

"@socket.io/redis-adapter": "^7.0.0",
"ioredis": "^4.27.6",

We using RedisAdapter extended:

module.exports = class OurOwnRedisAdapter extends RedisAdapter {
  constructor(nsp) {
    const options = Object.assign({
      pubClient,
      subClient: pubClient.duplicate(),
      requestsTimeout: 1000
    }, config.websocket.adapter);
    super(nsp, null, options);
  }
 ...
}

Our pubClient is created like this:

const pubClient = new Redis(_.merge(
    {
      dropBufferSupport: true // see https://github.com/luin/ioredis/wiki/Improve-Performance#dropbuffersupport-option
    },
    config.redis,
    scopedConfig,
    options,
    reconnectOnError,
  ));

And now we get this error that is difficult to know why.

 uncaughtException {
      error: TypeError: this.subClient.psubscribe is not a function
          at new RedisAdapter (/node_modules/@socket.io/redis-adapter/dist/index.js:64:24)
          at new OurOwnRedisAdapter (/lib/websocket-adapter.js:39:5)
          at Namespace._initAdapter (/node_modules/socket.io/dist/namespace.js:40:24)
          at Server.adapter (/node_modules/socket.io/dist/index.js:133:17)
          at module.exports (/lib/websocket.js:27:6)
          at Server.<anonymous> (/server.js:25:16)
          at Object.onceWrapper (events.js:421:28)
          at Server.emit (events.js:315:20)
          at emitListeningNT (net.js:1352:10)
          at processTicksAndRejections (internal/process/task_queues.js:79:21)
    }

This error happens when using 'redis' version 4.x.x, install version 3.x.x which works correctly.

@darrachequesne
Copy link
Member

@Morbden please check #417

Please also note that redis@4.0.0 has been released only 20 hours ago 👼

@mr-ryan-james
Copy link

mr-ryan-james commented Nov 28, 2021

This was bad timing for some of us who weren't aware of node redis v4 being a brand new thing 😄 I downgraded to v3 and it's working fine.

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

5 participants