Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETIMEDOUT error trying to connect to a Digitalocean managed Redis instance #1464

Closed
TAnas0 opened this issue Sep 10, 2019 · 5 comments
Closed

Comments

@TAnas0
Copy link

TAnas0 commented Sep 10, 2019

Description

Trying to connect to a remote Redis instance, hosted on Digital Ocean fails with the following error:

....
(node:10035) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT
    at Socket.<anonymous> (/root/gitlab/timer/node_modules/ioredis/built/redis/index.js:275:31)
    at Object.onceWrapper (events.js:277:13)
    at Socket.emit (events.js:189:13)
    at Socket._onTimeout (net.js:443:8)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:10035) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
....

Code to reproduce

I tried instantiating my queue both using a connection string and separated parameters:

var auditQueue = new Queue('audit', 'rediss://default:<my-password>@frontscan-timer-db-do-user-4570914-0.db.ondigitalocean.com:25061');
var auditQueue = new Queue('audit', {redis: {port: 25061, host: 'frontscan-timer-db-do-user-4570914-0.db.ondigitalocean.com', password: '<unguessable-password>', username: 'default'}});

Bull version

Bull version: v3.10.0
Redis server version: 5.0.4

Additional information

I was working with a local dockerized Redis server before, and the connection was working fine.

Please note that Digital Ocean requires me to whitelist trusted sources of connection, which include my computer's IP address and another Linux instance hosted on DO in the same region. I tried my code on both environments and it failed in the same way.
Also, Digital Ocean only accepts connection over SSL for Redis instances, which is the reason behind the prefix rediss://...

Also worth noting that I can connect to the Redis instance, from both my computer and the DO droplet, using redli:

redli --tls -h frontscan-timer-db-do-user-4570914-0.db.ondigitalocean.com -a <my-wonderful-password> -p 25061

I am not very Redis-savy, but I can provide further information about the Redis server since I have CLI access.

Questions

  1. I wasn't able to debug the error, and 'catch' the error in my code. Is the UnhandledPromiseRejectionWarning happening inside of BullJS? If so, how can I get more details?
  2. Is the rediss://... prefix enough for BullJS to perform the connection over SSL, as required by DO?
  3. What further information can I provide to help you help me?
@manast
Copy link
Member

manast commented Sep 11, 2019

Bull uses https://github.com/luin/ioredis#readme for connecting to Redis, so you should try a simple ioredis example and if does not work you can open an issue on ioredis repo instead.

@manast manast closed this as completed Sep 11, 2019
@ronalddddd
Copy link

For those looking for a solution with DO managed Redis, this worked for me: #1366 (comment)

Basically remember to have tls: {} and increase connection timeout with connectTimeout: 30000 in your redis queue config.

@BrunoQuaresma
Copy link

@ronalddddd do you have a sample of how to make it work? I'm still not getting it right :/

@manast
Copy link
Member

manast commented Jan 30, 2022

@BrunoQuaresma are you getting issues connecting with Bull or also with plain ioredis? I would recommend you to first try to connect using ioredis directly, you can pass this connection to Bull for example. If it does not work with ioredis then please fill an issue in that repo instead.

@BrunoQuaresma
Copy link

Thanks! I was able to get it working after reading the ioredis docs:

new Queue(
  "video",
  "rediss://default:<password>@<host>:25061",
  {
    redis: {
      tls: {},
      connectTimeout: 30000,
    }
  }
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants