Skip to content

Trying to subcribe pubsub topic but not getting anything #679

Description

@AP25

Hi,

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!!!

Activity

  1. jgeewax commented on Jun 19, 2015

    @jgeewax
    Contributor

    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?

  2. added
    type: questionRequest for information or clarification. Not an issue.
    api: pubsubIssues related to the Pub/Sub API.
    on Jun 19, 2015
  3. jgeewax commented on Jun 19, 2015

    @jgeewax
    Contributor

    Also -- this might be better asked over on StackOverflow unless it looks like a bug with gcloud.pubsub.

  4. AP25 commented on Jun 19, 2015

    @AP25
    Author

    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 ?

  5. jgeewax commented on Jun 19, 2015

    @jgeewax
    Contributor

    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);
    });
  6. AP25 commented on Jun 20, 2015

    @AP25
    Author

    Hi jgeewax ,

    Yes.Callback isn't get executed at all.Yes above code prints nothing.

  7. jgeewax commented on Jun 20, 2015

    @jgeewax
    Contributor
  8. AP25 commented on Jun 20, 2015

    @AP25
    Author

    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)

  9. jgeewax commented on Jun 21, 2015

    @jgeewax
    Contributor

    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.

  10. 11 remaining items

  11. added a commit that references this issue on Feb 26, 2026
  12. added a commit that references this issue on Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions