Skip to content

"error: Invalid protocol" #1380

@Heneros

Description

@Heneros

I followed by guide this nestjs redis and but still get the error: "error: Invalid protocol" . please tell me what to do?

redis.client.ts

import { Redis } from "@upstash/redis";
 
export const createRedisClient = (restUrl: string, restToken: string) => {
  const redis = new Redis({
    url: restUrl,
    token: restToken,
  });
  return redis;
};

redis.module.ts

import { Module } from '@nestjs/common';
import { RedisService } from './redis.service';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { RedisRepository } from './redis.repository';

import { createRedisClient } from './redis-client';

@Module({
    imports: [ConfigModule.forRoot({ isGlobal: true })],
    providers: [
        RedisService,
        {
            provide: 'RedisClient',
            useFactory: (config: ConfigService) => {
                const url = config.get<string>('REDIS_URL');
                const token = config.get<string>('REDIS_TOKEN');
                if (!url || !token) {
                    throw new Error('Empty fields');
                }

                return createRedisClient(url, token);
            },
            inject: [ConfigService],
        },
        RedisRepository,
    ],
    exports: [RedisService, RedisRepository],
})
export class RedisModule {}

my data in .env looks similiar like this:
UPSTASH_REDIS_REST_URL="https://us1-XXX-38101.upstash.io"
UPSTASH_REDIS_REST_TOKEN="AZTVACQXXXVhOTktYzI0Mi0XXXM4ZmQzMjI3NDY0NTZmNDXXXYjQ0NGY4MGYwNDI="

Please tell me what to do. Yesterday I tried contacting support, but they haven’t resolved my problem.

Does anyone have any idea what might be causing this issue? Where should I look for the mistake?

I’d really appreciate any help to solve my problem. Thank you!

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions