googleapis / google-cloud-node

Google Cloud Client Library for Node.js
https://cloud.google.com/nodejs
Apache License 2.0
2.9k stars 590 forks source link

503 Error when trying anything #294

Closed sdog869 closed 9 years ago

sdog869 commented 9 years ago
var gcloud = require('gcloud')({
  projectId: "project-id",
  credentials: require('./key.json')
});

var ds = gcloud.datastore.dataset();

I assume "project-id" is the same as the one I see inside the Google API Console.

I get:

{ [Error: Backend Error] errors: [], code: 503, message: 'Backend Error' }

Not sure what this means, I downloaded the service account json and I have enabled the appropriate APIs.

Thanks!

ryanseys commented 9 years ago

Awh, that's rough :( And Google should really give better errors. What exactly are you trying to do? Can you post your code snippet here?

sdog869 commented 9 years ago

I got it to work, I think it was the whole you can't use this with projects created under the old API Console thing. And I guess I didn't get that you had to attach it to a compute engine instance, so between those two it seems to be working outside of managed vms, not inside my managed vm I get 'invalid_grant'. Not sure why their would be a difference?

Code is:

ds.save({
  key: ds.key(['Company']),
  data: {
    'name': 'tacos'
  }
}, function(err) {
  if (err) {
    console.log(err);
    return;
  }
  res.send('Hello, world from ' + err);
});

var gcloud = require('gcloud')({
  projectId: "svgimageconverter",
  credentials: require('./svgimageconverter-e0779db28d94.json')
});

var ds = gcloud.datastore.dataset();
stephenplusplus commented 9 years ago

The code snippet will help, but I think this could be an issue on the Google developers console side. Here's a link to the page that lists project IDs: https://console.developers.google.com/project. Is the id you used under the project IDs column there?

stephenplusplus commented 9 years ago

Ignore the last post. Managed VMs plus Datastore is not a relationship that's perfected yet. However, using a private key inside the managed vms instance should work the same as locally.

// @proppy @silvolu for their expertise

sdog869 commented 9 years ago

I think on my localhost I had to do:

$ gcloud auth login

Could that be why it works outside of managed vm's but not inside? If so how do I add this to my Docker file? I noticed it pops a URL and I have to manually authorize it so I imagine this won't be possible with a managed vm/docker image right, so how do I accomplish it? Thanks!

silvolu commented 9 years ago

@sdog869 yes, if you were using an old project, your dataset ID would be the App Engine application ID instead of the Developer Console project id, but I don't understand what is going on with the rest of your isses. Is gcloud-node that is not working or the gcloud command line tool (the one you use to gcloud auth login and similar).?

stephenplusplus commented 9 years ago

@sdog869 any updates on this? Hope everything is working out okay!

ryanseys commented 9 years ago

Closing because he said he got it to work :)

janakaud commented 6 years ago

Just for the benefit of anyone bumping into this issue in the future, the 503 error could also arise if your request payload is missing some required parameters.

Happened to me while trying an insert on the Deployment Manager API, where I had forgotten to specify the name parameter.

Naturally I was expecting something like a 400 (Bad Request) error, but it turned out to be a 503 with a similar backendError reason but a bit more descriptive message.

{ domain: 'global',
       reason: 'backendError',
       message: 'An internal error occurred. Please retry and contact support if the issue persists. Error ID: \'-6941930019126389974\'' }
r3lik commented 3 years ago

For anyone that runs into a similar cryptic error, for me it was missing Context