首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >google/ pubsub /v1/pubsub.proto在/protos中找不到

google/ pubsub /v1/pubsub.proto在/protos中找不到
EN

Stack Overflow用户
提问于 2018-12-01 13:38:49
回答 1查看 263关注 0票数 0

我试图从firebase云函数发布一条json消息到发布子主题,我使用的是pubsubVersion0.19.0。

我得到了这个错误:

代码语言:javascript
复制
google/pubsub/v1/pubsub.proto could not be found in /protos
    at Function.GrpcClient._resolveFile (/srv/node_modules/google-gax/lib/grpc.js:174:9)
    at GrpcClient.loadProto (/srv/node_modules/google-gax/lib/grpc.js:162:33)
    at new PublisherClient (/srv/index.js:6842:15)
    at PubSub../node_modules/@google-cloud/pubsub/src/index.js.PubSub.getClient_ (/srv/index.js:3985:17)
    at PubSub../node_modules/@google-cloud/pubsub/src/index.js.PubSub.request (/srv/index.js:4006:8)
    at Publisher../node_modules/@google-cloud/pubsub/src/publisher.js.Publisher.publish_ (/srv/index.js:4404:14)
    at ontimeout (timers.js:482:11)
    at tryOnTimeout (timers.js:317:5)
    at Timer.listOnTimeout (timers.js:277:5)

这是我的代码:

代码语言:javascript
复制
const pubsub = new PubSub();
const topic = pubsub.topic(PUBSUB_TOPIC_NAME);
const publisher = topic.publisher();
const dataBuffer = Buffer.from(JSON.stringify(req.body));
publisher
.publish(dataBuffer)
.then(messageId => {
  console.log(`Message ${messageId} published.`);
  res.status(200).send('Message published.');
})
.catch(err => {
  console.error('ERROR:', err);
  res.status(500).send(err);
  return Promise.reject(err);
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-02 22:07:34

通过安装protos库可以解决此错误:

代码语言:javascript
复制
pip install -U googleapis-common-protos

注意:您正在使用的Pub/Sub版本是旧的。当前版本是0.39.0。更新:pip install -U google-cloud-pubsub

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53571340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档