question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: this.subClient.psubscribe is not a function

See original GitHub issue

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)
    }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
darrachequesnecommented, Nov 25, 2021

@Morbden please check https://github.com/socketio/socket.io-redis-adapter/issues/417

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

1reaction
darrachequesnecommented, Jul 8, 2021

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);
  }
 ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

socket.io-redis-adapter with redis 4
Error TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer. Received type function ...
Read more >
socket.io-redis
The redis adapter instances expose the following properties that a regular Adapter does not. uid; prefix; pubClient; subClient; requestsTimeout ...
Read more >
socket.io-redis
The Redis adapter extends the broadcast function of the in-memory adapter: the ... redis-cli 127.0.0.1:6379> PSUBSCRIBE * Reading messages.
Read more >
Redis adapter
io.adapter(createAdapter(pubClient, subClient)); ... Note: with redis@3 , calling connect() on the Redis clients is not needed:.
Read more >
"TypeError: require(...).listen is not a function" in socket.io
In this video I have shown " TypeError : require(...).listen is not a function "that you might face with connecting to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found