【发布时间】:2020-11-21 15:05:26
【问题描述】:
我正在尝试在 Google Cloud 上运行我的 redis 公牛。在本地一切正常。
我在服务器启动时使用以下代码:
const client = redis.createClient('6379', '10.103.YYY.YYY');
这似乎有效。我在启动时没有收到任何错误。
当我尝试与 Bull 一起工作时:
const actionQueue = new Bull(uuid(), {
redis: {
port: 6379, host: '10.103.YYY.YYY', tls: {
servername: '10.103.YYY.YYY'
}
}
});
await actionQueue.add();
actionQueue.process(async (job) => {
return this._job();
});
actionQueue.on('completed', async (job, actionId) => {
console.log(`Job completed with result ${actionId}`);
});
actionQueue.on("failed", (job, error) => {
console.log(job.id, error);
});
但是redis仍然连接到localhost ip&port。有人知道为什么这仍然连接到我的本地主机吗?我需要以不同的方式进行设置吗?
错误日志:
2020-11-21T14:55:35.794783Z <rejected> Error: connect ECONNREFUSED 127.0.0.1:6379
Standaard
2020-11-21T14:55:35.794791Z at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16) {
Standaard
2020-11-21T14:55:35.794798Z errno: 'ECONNREFUSED',
Standaard
2020-11-21T14:55:35.794804Z code: 'ECONNREFUSED',
Standaard
2020-11-21T14:55:35.794810Z syscall: 'connect',
Standaard
2020-11-21T14:55:35.794816Z address: '127.0.0.1',
Standaard
2020-11-21T14:55:35.794822Z port: 6379
Standaard
2020-11-21T14:55:35.794828Z }
Standaard
2020-11-21T14:55:35.794834Z}
Standaard
2020-11-21T14:55:35.794987Z The error was: Error: connect ECONNREFUSED 127.0.0.1:6379
Standaard
2020-11-21T14:55:35.794994Z at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16) {
Standaard
2020-11-21T14:55:35.795Z errno: 'ECONNREFUSED',
Standaard
2020-11-21T14:55:35.795006Z code: 'ECONNREFUSED',
Standaard
2020-11-21T14:55:35.795011Z syscall: 'connect',
Standaard
2020-11-21T14:55:35.795017Z address: '127.0.0.1',
Standaard
2020-11-21T14:55:35.795022Z port: 6379
Standaard
2020-11-21T14:55:35.795028Z}
【问题讨论】:
-
将
new Bull替换为new Queue并告诉我是否更好 -
我用于 init : const Bull = require('bull');
-
你知道我是否需要配置一些东西来允许连接谷歌云运行 Redis 服务?
-
如果您的 localhost 问题得到解决,是的,Cloud Run 上还有一个额外的配置要执行
-
你能帮我看看哪个配置吗?
标签: node.js redis google-cloud-run