在GCP PubSub中收到任何响应之前,重试了总超时时间 [英] Retry total timeout exceeded before any response was received in GCP PubSub

查看:205
本文介绍了在GCP PubSub中收到任何响应之前,重试了总超时时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用@google-cloud/pubsub模块在节点js中推送到PubSub主题 这是Javascript代码

I am trying to push to PubSub Topic in node js using @google-cloud/pubsub module Here is Javascript code

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
   } 

推荐答案

我通过在package.json中添加以下"google-gax":"1.6.2"来解决了此问题

I solved this problem by adding this "google-gax": "1.6.2" in package.json

@ grpc/grpc-js @ 0.6.x存在内存泄漏问题. google-gax需要grpc,而pubsub,cloud-task和其他google模块则需要grpc.

@grpc/grpc-js@0.6.x has memory leak issues. grpc was required by google-gax which in turn was required by pubsub, cloud-task, and other google modules.

此处 查看全文

相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆