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

Rediss:// connection returns error #348

Open
melishev opened this issue Sep 17, 2022 · 2 comments
Open

Rediss:// connection returns error #348

melishev opened this issue Sep 17, 2022 · 2 comments

Comments

@melishev
Copy link

melishev commented Sep 17, 2022

Current Behavior

I'm trying to connect to my Digital Ocean hosted Redis database using this configuration:

RedisModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: async (configService: ConfigService) => {

        return {
          readyLog: true,
          config: {
            url: 'rediss://default:<password>@<host>:25061',
          },
        };
      },
    }),

I take the connection string from DO, and it is correct. But when I try to connect, I get an error:

var err = new errorClasses.AbortError(error_attributes);
                      ^
AbortError: Redis connection lost and command aborted. It might have been processed.
    at RedisClient.flush_and_error (/Users/***/Desktop/server/node_modules/redis/index.js:298:23)
    at RedisClient.connection_gone (/Users/***/Desktop/server/node_modules/redis/index.js:603:14)
    at Socket.<anonymous> (/Users/***/Desktop/server/node_modules/redis/index.js:231:14)
    at Object.onceWrapper (node:events:641:28)
    at Socket.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
    at new Command (/Users/***/Desktop/server/node_modules/redis/lib/command.js:12:22)
    at RedisClient.info (/Users/***/Desktop/server/node_modules/redis/lib/individualCommands.js:169:39)
    at RedisClient.ready_check (/Users/***/Desktop/server/node_modules/redis/index.js:470:10)
    at RedisClient.on_connect (/Users/***/Desktop/server/node_modules/redis/index.js:364:14)
    at Socket.<anonymous> (/Users/***/Desktop/server/node_modules/redis/index.js:213:14)
    at Object.onceWrapper (node:events:641:28)
    at Socket.emit (node:events:539:35)
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1173:10)

I believe this error is related to SSL/TLS connection and configuration

Context

Sorry if my problem is stupid or already solved. I am new to Redis

Your Environment

  • Version used: 8.2.2
  • NestJS version: 8.0.0
  • Node.js version: 16.15.0
  • Operating System and version (macOS, Windows, Linux): macOS
@liaoliaots
Copy link
Owner

@melishev Unfortunately, I have no credit card to create Digital Ocean managed redis instances.
For testing purposes, you can try to connect to your redis instance via redli or RedisOptions(use ioredis directly) like this:

redli --tls -h redis-test-do-user-4915853-0.db.ondigitalocean.com -a your_password -p 25061
const Redis = require('ioredis');
const fs = require('fs');

const redis = new Redis({
    host: 'hostname',
    port: <port>,
    tls: {
        key: fs.readFileSync('path_to_keyfile', 'ascii'),
        cert: fs.readFileSync('path_to_certfile', 'ascii'),
        ca: [ fs.readFileSync('path_to_ca_certfile', 'ascii') ]
    }
});

Releated links:
redis/ioredis#1076 (comment)
https://docs.redis.com/latest/rs/references/client_references/client_ioredis/
https://docs.redis.com/latest/rs/security/
https://redis.io/docs/manual/security/

@hellogerard
Copy link

FWIW, I did not have this problem with this package using just Redis commands. However, I did have this problem when using @nestjs/bull. I found this solution on the main bull repo: OptimalBits/bull#1464 (comment)

So you might try:

RedisModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: async (configService: ConfigService) => {
        return {
          readyLog: true,
          config: {
            redis: {
              tls: {},
              connectTimeout: 30000,
            },
            url: 'rediss://default:<password>@<host>:25061',
          },
        };
      },
    }),

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

3 participants