在 GCP PubSub 中收到任何响应之前超过重试总超时
Retry total timeout exceeded before any response was received in GCP PubSub
我正在尝试使用 @google-cloud/pubsub
模块推送到节点 js 中的 PubSub 主题
这是 Javascript 代码
const { pubsub } = require('@google-cloud/pubsub');
class MyPubSub {
constructor(container) {
this.publisherUser = pubsub.topic(
this.config.pubSubToBigQueryTopicName, {
batching: {
"maxMessages": 1
}
});
}
publishToPubSub(data) {
let MAX_RETRIES = 3;
return new Promise(async (resolve, reject) => {
if (!data) {
return reject(`Invalid param ${data}`);
}
const dataBuffer = Buffer.from(JSON.stringify(data));
let err, id, cx = 0;
do {
[err, id] = await this.utility.invoker(this.publisherUser.publish(dataBuffer));
cx++;
} while (err && cx <= MAX_RETRIES);
if (err) {
return reject(err);
}
return resolve(id);
});
}
}
module.exports = MyPubSub;
但收到此错误
error: {
"stack":"Error: Retry total timeout exceeded before any response was received\n
at repeat (/my-service/node_modules/@google-cloud/pubsub/node_modules/google-gax/build/src/normalCalls/retries.js: 80: 31)\n
at Timeout.setTimeout
[as _onTimeout] (/my-service/node_modules/@google-cloud/pubsub/node_modules/google-gax/build/src/normalCalls/retries.js: 113: 25)\n
at ontimeout (timers.js: 498: 11)\n
at tryOnTimeout (timers.js: 323: 5)\n
at Timer.listOnTimeout (timers.js: 290: 5)",
"message":"Retry total timeout exceeded before any response was received",
"code":4
}
publish 已经退休。您不需要自己实施。你只需要配置它。
但潜在的问题是:https://github.com/googleapis/nodejs-pubsub/issues/770 仍处于打开状态。
我通过在 package.json
中添加 "google-gax": "1.6.2" 解决了这个问题
@grpc/grpc-js@0.6.x 存在内存泄漏问题。 google-gax 需要 grpc,而 pubsub、cloud-task 和其他 google 模块又需要 grpc。
我正在尝试使用 @google-cloud/pubsub
模块推送到节点 js 中的 PubSub 主题
这是 Javascript 代码
const { pubsub } = require('@google-cloud/pubsub');
class MyPubSub {
constructor(container) {
this.publisherUser = pubsub.topic(
this.config.pubSubToBigQueryTopicName, {
batching: {
"maxMessages": 1
}
});
}
publishToPubSub(data) {
let MAX_RETRIES = 3;
return new Promise(async (resolve, reject) => {
if (!data) {
return reject(`Invalid param ${data}`);
}
const dataBuffer = Buffer.from(JSON.stringify(data));
let err, id, cx = 0;
do {
[err, id] = await this.utility.invoker(this.publisherUser.publish(dataBuffer));
cx++;
} while (err && cx <= MAX_RETRIES);
if (err) {
return reject(err);
}
return resolve(id);
});
}
}
module.exports = MyPubSub;
但收到此错误
error: {
"stack":"Error: Retry total timeout exceeded before any response was received\n
at repeat (/my-service/node_modules/@google-cloud/pubsub/node_modules/google-gax/build/src/normalCalls/retries.js: 80: 31)\n
at Timeout.setTimeout
[as _onTimeout] (/my-service/node_modules/@google-cloud/pubsub/node_modules/google-gax/build/src/normalCalls/retries.js: 113: 25)\n
at ontimeout (timers.js: 498: 11)\n
at tryOnTimeout (timers.js: 323: 5)\n
at Timer.listOnTimeout (timers.js: 290: 5)",
"message":"Retry total timeout exceeded before any response was received",
"code":4
}
publish 已经退休。您不需要自己实施。你只需要配置它。
但潜在的问题是:https://github.com/googleapis/nodejs-pubsub/issues/770 仍处于打开状态。
我通过在 package.json
中添加 "google-gax": "1.6.2" 解决了这个问题@grpc/grpc-js@0.6.x 存在内存泄漏问题。 google-gax 需要 grpc,而 pubsub、cloud-task 和其他 google 模块又需要 grpc。