简体   繁体   中英

Nodejs Bull queue not connecting to Azure

When changing the settings inside the new bull Queue object, I get an error in the console. When running Bull Queue locally the application works perfectly fine. As soon as I change the credentials to Azure, I get the error below. When running locally I run the redis-server but not when using the Azure credentials.

I have tried the example tutorial, on the Azure website, with nodejs and the redis npm package, and the Azure redis cache works perfectly fine. Therefore, I am left to believe that I am doing something wrong in the config. I have also tried adding "maxRetriesPerRequest" and "enableReadyCheck" to the redis object however, they have had no effect. I also make sure I execute the done function within the process function.

const queue = new Queue('sendQueue', {
  defaultJobOptions: { removeOnComplete: true },
  redis: {
    port: env.AZURE_REDIS_PORT,
    host: env.AZURE_REDIS_HOST,
    password: env.AZURE_REDIS_PASSWORD
  },
});
at Queue.<anonymous> (/Users/abc/Projects/Sean/dist/tasks/sendQueue.js:47:11)
 at Queue.emit (events.js:208:15)
 at Redis.emit (events.js:203:13)
 at Redis.silentEmit (/Users/abc/Projects/Sean/node_modules/ioredis/built/redis/index.js:482:26)
 at Socket.<anonymous> (/Users/abc/Projects/Sean/node_modules/ioredis/built/redis/event_handler.js:122:14)
 at Object.onceWrapper (events.js:291:20)
 at Socket.emit (events.js:203:13)
 at emitErrorNT (internal/streams/destroy.js:91:8)
 at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
 at processTicksAndRejections (internal/process/task_queues.js:77:11)
Error: read ECONNRESET
 at TCP.onStreamRead (internal/stream_base_commons.js:183:27)

Try to add configuration for TLS when using Azure redis cache. Should be the same config value as host. I did not manage to get a connection without it.

var notificationQueue = new Queue('notifications', {
  redis: {
    port: Number(process.env.REDIS_PORT), 
    host: process.env.REDIS_HOST, 
    password: process.env.REDIS_PASS, 
    tls: {
      servername: process.env.REDIS_HOST
    }
  }});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM