Google pubsub 错误 google/pubsub/v1/pubsub.proto 无法在 /protos 中找到
Google pubsub error google/pubsub/v1/pubsub.proto could not be found in /protos
我正在尝试从 firebase 云功能向 pubsub 主题发布 json 消息,我使用的是 pubsub 版本 0.19.0。
我收到这个错误:
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)
这是我的代码:
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);
});
这个错误可以通过安装 protos
库来解决:
pip install -U googleapis-common-protos
注意:您使用的Pub/Sub版本是旧版本。当前版本为 0.39.0
。更新:pip install -U google-cloud-pubsub
我正在尝试从 firebase 云功能向 pubsub 主题发布 json 消息,我使用的是 pubsub 版本 0.19.0。
我收到这个错误:
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)
这是我的代码:
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);
});
这个错误可以通过安装 protos
库来解决:
pip install -U googleapis-common-protos
注意:您使用的Pub/Sub版本是旧版本。当前版本为 0.39.0
。更新:pip install -U google-cloud-pubsub