GeezerVison is showing github.com — Trying to subcribe pubsub topic but not getting anything · Issue #679 · googleapis/google-cloud-node
Trying to subcribe pubsub topic but not getting anything #679DescriptionHi,
I am trying to subscribe created topic on pubsub for that i am using
var gcloud = require('gcloud');
var pubsub1 = gcloud.pubsub({
projectId: 'ProjectID',
keyFilename: KeyFile(Buffer format)
});
pubsub1.createTopic('topicName', function(err, topic) {
});
var _topicCreated = pubsub1.topic('topicName')
_topicCreated.subscribe('newSubscription', function(err, subscription) {
});
But using this i am not getting callback of subscription. Is anything missing in this request?
Thanks in advance!!! Activityjgeewax commented on Jun 19, 2015 What exactly is going on in keyFilename: KeyFile(Buffer format) ? keyFilename should be a path to a .json file you get via the Cloud Console (see http://googlecloudplatform.github.io/gcloud-node/#/authorization for more on that).
Can you also clarify what you mean by "not getting callback of subscription"? You mean the callback is not being executed? Did you try adding console.log(err) inside each of the callbacks to see what's happening? jgeewax commented on Jun 19, 2015 Also -- this might be better asked over on StackOverflow unless it looks like a bug with gcloud.pubsub. AP25 commented on Jun 19, 2015 Hi jgeewax,
Yes i am using keyFilename as .json file of cloud console.I am not getting callback of subscription means i added console.log(err) and console.log(subscription).But i didn't get any error or subscription log.
Same thing happened while creating topic.I didn't get error log also.
So is that topic is created? and how can i subscribe to that topic ? jgeewax commented on Jun 19, 2015 You're saying that the callback isn't getting executed at all?
As in, running the following prints out nothing?
var gcloud = require('gcloud');
var pubsub = gcloud.pubsub({
projectId: 'purple-spaceship-123', // or whatever your project ID is.
keyFilename: '~/keyfile.json' // or the path to your keyfile
});
pubsub.createTopic('topicName', function(err, topic) {
console.log('Response was', err, topic);
});AP25 commented on Jun 20, 2015 Hi jgeewax ,
Yes.Callback isn't get executed at all.Yes above code prints nothing. jgeewax commented on Jun 20, 2015 Can you put console.log statements around the calls to see what's up? In
short... Even if there is an error, it should execute the callback with the
error, the only reason for it not to run at all is if there is an error in
your code elsewhere preventing the createTopic method from being executed
at all.... AP25 commented on Jun 20, 2015 Hi jgeewax,
Thanks i have created topic successfully. I want to create watch on that pub/sub topic.For that i am using rest request as
request_Req.post({
url:'https://www.googleapis.com/gmail/v1/users/me/watch',
headers:{
'content-type': 'application/json',
'Authorization': 'Bearer '+ access_token,
},
scope : [
'https://mail.google.com/'
],
'body': JSON.stringify({
'topicName' : "/projects/ProjectId/topics/TopicId",
'labelIds' : ["INBOX"]
});
}),function(error, resp, body){
});
But after executing this code i am getting error as sending test message to Cloud
PubSub/projects/ProjectID/topics/TopicId : Resource not found(resource=TopicId) jgeewax commented on Jun 21, 2015 Hi @AP25 ,
Did you figure out what the problem was ? (So that others reading this could solve it themselves?)
It looks like your next question isn't really about this library, so you might want to take it over to Stack Overflow to see if someone can help out.
I'm going to resolve this issue (but still would love to hear how you fixed the first issue!), feel free to re-open if I misunderstood and this is either a bug or a question about gcloud-node.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|