I am facing Issue While Connecting Upstash Redis Instance with bullMQ

I am using ioRedis to connect Instance

const redisConnection = new Redis({
host: config.redis.redisHost,
port: Number(config.redis.redisPort),
password: config.redis.redisPassword,
maxRetriesPerRequest: null,
tls: {},
connectTimeout:30000,
lazyConnect: true,
keepAlive: 10000,
});

const knowledgeQueue = new Queue(“knowledgeQueue”, {
connection: redisConnection,
settings: settings as AdvancedRepeatOptions,
});

I have created Queue Here
const workerInstance = new Worker(“knowledgeQueue”, workerJobHandler, {
connection: redisConnection,
});

async function workerJobHandler(job: Job) {
const { knowledge, user } = job.data;
try {
const fileResponse = await fetch(knowledge.fileUrl);

if (!fileResponse.ok) {
  return { success: false, knowledge, user };
}

const blob = (await fileResponse.blob()) as Blob;
await trainData(knowledge.fileType, blob, user!.id);
return { success: true, knowledge, user };

} catch (error) {
return { success: false, knowledge, user };
}
}

workerInstance.on(“completed”, async (job, result) => {
const { knowledge, user } = result;

const knowledgeId = knowledge.id as number;

await updateKnowledge(knowledgeId, {
isTraining: false,
trainedAt: new Date(),
});

io.emit(“knowledge-added”, { knowledge, owner: user });
});

**It is working fine if I am using my Redis Locally. **

I am facing issue like Connection TImeout.

Your Redis instance uses an IPv6 address, so you might try family: 6 to the IORedis options.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.