Connect to Redis instance using ioredis

Hi all, I’m trying to connect my meteor server to a remote redis instance using ioredis. I’m able to connect to the instance successfully using a regular node server, but with my meteor server I keep getting a NOAUTH Authentication required error. If I use the wrong password, I get an error saying it’s the wrong password.

I think this has to do with the nature of Meteor’s threading and is not related to my configuration. Does anyone know if I should be using wrapAsync or some other sort of function on the server to make this work? Here is a sample of my configuration here:

  import Redis from 'ioredis';

  const connection = {
    port: Meteor.settings.private.redis.port,
    password: Meteor.settings.private.redis.password,

  const Redis = new Redis(connection);

const Redis = new Redis(connection);

That doesn’t look good. Maybe try a variable name not the same as the class name?

Several methods in ioredis use callbacks or return Promises. If you want to use callbacks, you may need to use Meteor.wrapAsync or Meteor.bindEnvironment to ensure the fiber is preserved (it’s not always needed). However, you can use Promises and async/await instead of callbacks, which removes the requirement for binding the fiber.

Ah yeah, the Redis variable is incorrect here…I just posted it wrong. Instantiating a redis client doesn’t require a callback, so I don’t think wrapAsync is the right call, but I will look into bindEnvironment a little later tonight. Good call…thanks!