m-allanson / bullmq-redis-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About

Debugging redis connection errors with BullMQ. I was getting:

[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)

Note that the port 6379 is not the port provided in REDIS_URL.

This is because the QueueEvents constructor requires connection options. This seems obvious in retrospect, but it's not mentioned in the docs.

The API docs mention that option, but it's tucked away in QueueEvents.(constructor) --> QueueEventsOptions interface --> QueueBaseOptions interface

Requirements

  • A local redis server running on a non-standard port. 5555 is used in this demo.
  • Node.js v14+ (for esm support)

Getting started

  • npm install
  • npm run start

Output

❯ npm run start

> bull-redis@1.0.0 start /Users/mike/d/temp/bull-redis
> REDIS_URL=redis://127.0.0.1:5555 node index.js

redis is:  ready

About


Languages

Language:JavaScript 100.0%