Not being able to connect to azure redis service

I have a webapp deployed in azure, and I´ve also configured a azure redis cache, but I am not being able to make my cache work. My nextjs frontend app is hosted in vercel.

This is my redis client in my nodejs app:

const redis = require("redis");
const dotenv = require('dotenv');

dotenv.config({ path: './.env' });

// Variables de entorno para la caché
const cacheHostName = process.env.AZURE_CACHE_FOR_REDIS_HOST_NAME;
const cachePassword = process.env.AZURE_CACHE_FOR_REDIS_ACCESS_KEY;

if (!cacheHostName) throw new Error("AZURE_CACHE_FOR_REDIS_HOST_NAME is empty");
if (!cachePassword) throw new Error("AZURE_CACHE_FOR_REDIS_ACCESS_KEY is empty");

exports.connect = async () => {
  let client;

  if (process.env.NODE_ENV === 'production') {
    client = redis.createClient({
      // Configuración de Redis para TLS en producción
      url: `redis://${cachePassword}@${cacheHostName}:6380`,
      tls: {
        rejectUnauthorized: true // Asegúrate de que este valor sea verdadero para requerir SSL
      }
    });
  } else {
    // Configuración local de Redis para pruebas
    client = redis.createClient({
      host: 'localhost',
      port: 6379
    });
  }

  client.on('connect', () => {
    console.log('Cliente Redis conectado al servidor');
  });

  client.on('error', (err) => {
    console.error('El cliente Redis no pudo conectarse al servidor:', err);
  });

  client.on('end', () => {
    console.log('La conexión del cliente Redis se cerró');
  });

  await client.connect();

  return client;
};

My SSL port in the redis service is disabled and my SSL port is 6380, and the TLS version is 1.2

Everytime I make a request through postman or through my hosted app, the request stays in an infinite Sending request....

I have also tried with rejectUnauthorized: false and no changes were shown.

It seems that my redis client is connecting and failing connection in an inifinite loop:

Cliente Redis connected to the server
The Redis Client was not able to connect to the server: Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:218:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}
El cliente Redis no pudo conectarse al servidor: Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:218:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}
Cliente Redis connected to the server
The Redis Client was not able to connect to the server: Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:218:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}
The Redis Client was not able to connect to the server: Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:218:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}
Cliente Redis connected to the server

This is how I am handling redis in my controller method.

const { User } = require('../models');
const asyncHandler = require('../middlewares/async');
const { connect } = require('../redis/redis')

//@route    GET api/users/
//@desc     Get all users
//@access   Private
exports.getUsers = asyncHandler(async (req, res, next) => {
   const redis = await connect();

   const key = 'users';
   const redisUsers = await redis.get(key);

   if( redisUsers ) {
      console.log('Users From Redis')
      return res.status(200).json({
         success: true,
         data: JSON.parse(redisUsers)
      })
   }
      
   console.log('Users From DB')
   const users = await User.findAll();
   await redis.set(key, JSON.stringify(users));
   return res.status(200).json({
      success: true,
      data: users
   })
});

In my local environment if I connect to redis to port 6379 and to host localhost it works fine, but as soon as I try connecting to the service of redis in azure it fails.

In the network tab of the browser when I make a request going to a view that displays a list of users I get the request for long time with no status code and finally I get a CORS error but CORS is enabled from azure. Finally the response from my frontend is of type text/x-component instead of json.

Note: this error only occurs in requests that include redis in my server

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật