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

Cluster subscribe does not work when TLS is enabled for AWS Redis Cluster #791

Closed
andrewm42 opened this issue Feb 1, 2019 · 2 comments
Closed
Labels

Comments

@andrewm42
Copy link

andrewm42 commented Feb 1, 2019

Tested Using

  • Node.js v10.13.0
  • ioredis v4.5.1
  • AWS Clustered Redis Elasticache (3 nodes, in-transit and at-rest encryption enabled)

Problem

Disabling TLS breaks the pub/sub subscribe functions for me. I have tried everything in this post: #754 to resolve it but I always get this error:

MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details

Example

This occurs when using the simple example below:

  const nodes = [{
      host: ...,
      port: ...,
  }];
  const redisOptions = {
      tls: {},
  };
  const clusterOptions = {
      redisOptions: redisOptions,
      dnsLookup: (address, callback) => callback(null, address),
  };

  const redis = new Redis.Cluster(nodes, clusterOptions);
  const pub = new Redis.Cluster(nodes, clusterOptions);

  redis.subscribe('mychannel1', (err, count) => {
    console.log(err);
    pub.publish('mychannel1', 'Hello world!');
  });

  redis.on('message', (channel, message) => {
    console.log(`Received message ${message} from channel ${channel}`);
  });

Publish works fine. Subscribe does not. Has anyone else encountered this error?

@r3b-fish
Copy link
Contributor

r3b-fish commented Feb 2, 2019

It's possible solution but I think instantiation of subscriber should be more elegant

diff --git a/lib/cluster/ClusterSubscriber.ts b/lib/cluster/ClusterSubscriber.ts
index 11c1e0b..c176bec 100644
--- a/lib/cluster/ClusterSubscriber.ts
+++ b/lib/cluster/ClusterSubscriber.ts
@@ -71,7 +71,8 @@ export default class ClusterSubscriber {
       password: options.password,
       enableReadyCheck: true,
       connectionName: SUBSCRIBER_CONNECTION_NAME,
-      lazyConnect: true
+      lazyConnect: true,
+      tls: options.tls
     })

@luin luin closed this as completed in 32c48ef Feb 2, 2019
ioredis-robot pushed a commit that referenced this issue Feb 2, 2019
## [4.6.2](v4.6.1...v4.6.2) (2019-02-02)

### Bug Fixes

* subscriber initialization when using Cluster ([#792](#792)) ([32c48ef](32c48ef)), closes [#791](#791)
@ioredis-robot
Copy link
Collaborator

🎉 This issue has been resolved in version 4.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

janus-dev87 added a commit to janus-dev87/ioredis-work that referenced this issue Mar 1, 2024
## [4.6.2](redis/ioredis@v4.6.1...v4.6.2) (2019-02-02)

### Bug Fixes

* subscriber initialization when using Cluster ([#792](redis/ioredis#792)) ([32c48ef](redis/ioredis@32c48ef)), closes [#791](redis/ioredis#791)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants