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

Shared PubSub compatiable issue with ioredis #499

Closed
ngot opened this issue May 10, 2023 · 1 comment
Closed

Shared PubSub compatiable issue with ioredis #499

ngot opened this issue May 10, 2023 · 1 comment
Milestone

Comments

@ngot
Copy link

ngot commented May 10, 2023

iosredis added the ssubscribe support https://github.com/luin/ioredis/pull/1690/files

but their API is ssubscribe rather than sSubscribe, same with the sPublish vs spublish.

TypeError: this.subClient.sSubscribe is not a function

I believe we might need to have the workaround like this

const isRedisV4 = typeof this.pubClient.pSubscribe === "function";
    if (isRedisV4) {
      this.redisListeners.set("psub", (msg, channel) => {
        this.onmessage(null, channel, msg);
      });

      this.redisListeners.set("sub", (msg, channel) => {
        this.onrequest(channel, msg);
      });

      this.subClient.pSubscribe(
        this.channel + "*",
        this.redisListeners.get("psub"),
        true
      );
      this.subClient.subscribe(
        [
          this.requestChannel,
          this.responseChannel,
          this.specificResponseChannel,
        ],
        this.redisListeners.get("sub"),
        true
      );
    } else {
      this.redisListeners.set("pmessageBuffer", this.onmessage.bind(this));
      this.redisListeners.set("messageBuffer", this.onrequest.bind(this));

      this.subClient.psubscribe(this.channel + "*");
      this.subClient.on(
        "pmessageBuffer",
        this.redisListeners.get("pmessageBuffer")
      );

      this.subClient.subscribe([
        this.requestChannel,
        this.responseChannel,
        this.specificResponseChannel,
      ]);
      this.subClient.on(
        "messageBuffer",
        this.redisListeners.get("messageBuffer")
      );
    }
darrachequesne added a commit that referenced this issue May 13, 2023
@darrachequesne
Copy link
Member

This should be fixed by 42c8ab6, included in release 8.2.1.

Please note that there seems to be an issue with the ssubscribe() command against a Redis cluster: redis/ioredis#1759

@darrachequesne darrachequesne added this to the 8.2.1 milestone May 15, 2023
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

2 participants