最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

在GCP PubSub中收到任何响应之前已超过重试总超时时间

运维笔记admin17浏览0评论

在GCP PubSub中收到任何响应之前已超过重试总超时时间

在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/googleapis/nodejs-pubsub/issues/770仍然打开。

发布评论

评论列表(0)

  1. 暂无评论