node.js - 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)
解决方案
尝试在使用 Azure redis 缓存时添加 TLS 配置。应该与主机的配置值相同。没有它,我无法建立连接。
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
}
}});
推荐阅读
- reactjs - 从 React 应用程序发出套接字 io 事件并且在 Node js 服务器上没有接收到它
- awk - awk:将行号与结束的正则表达式模式匹配
- python - python3中open()函数的文件路径有问题
- c++ - 在 C++ 中的字符串函数的返回语句中设置精度内联
- python - 使用“left”和“right”参数使用 numpy interp 进行外推
- linux - Index.php:在 apache 中找不到文件
- c++ - C ++中除差表中的牛顿多项式
- oracle - 如何在 oracle 数据库上自动存储图像?
- javascript - JavaScript、提示和 for 循环的新手?
- python - 错误:对于 pygame.event.get() 中的事件:pygame.error:视频系统未初始化