Loop in Express Server with ioredis: Unhandled 'ECONNRESET' Error and MaxRetriesPerRequestError

137 Views Asked by At

What can cause this kind of error?

[ioredis] Unhandled error event: Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)

When I launch a Request the responses is okay but after some request my server shutDown with that error.

[ERROR] 14:18:43 MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.

Is the error from this code?

server\utils\redis.ts

import { Redis } from "ioredis";

require("dotenv").config();
const redisClient = () => {
  if (process.env.REDIS_URL) {
    console.log(`Redis connected`);
    return process.env.REDIS_URL;
  }
  throw new Error("Redis connection failed");
};

export const redis = new Redis(redisClient());

You can check all my code on this GitHub link.

0

There are 0 best solutions below