When I use the library: @google-cloud/pubsub method to get the topic created in gcloud pub/sub, I get the following error:
Total timeout of API google.pubsub.v1.Publisher exceeded 60000 milliseconds before any response was received.
I have configured the ADC locally and set the environment variables, I think it is not caused by this.
version:
“@google-cloud/pubsub”: “^4.5.0”
const {PubSub} = require('@google-cloud/pubsub');
// Creates a client; cache this for further use
const pubSubClient = new PubSub();
async function listAllTopics() {
// Lists all topics in the current project
const [topics] = await pubSubClient.getTopics();
console.log('Topics:');
topics.forEach(topic => console.log(topic.name));
}
function main(){
listAllTopics().catch(err => {
console.error(err.message);
process.exitCode = 1;
});
}
main()
Try to use the api key method for authentication, but still get the same error
const pubSubClient = new PubSub({
projectId: "demo",
credentials: {
client_email: "xxxxxxxxxx",
private_key: "xxxxxxxxxxxxx",
},
});
New contributor
liang shen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.