Skip to content

API requests hang indefinitely #1955

Closed
Closed

Description

@goshoo

Hi,

I'm using google datastore API and if I run my application from my local computer then the application connects to the datastore, but if I deploy the application it cannot connect to the datastore.

Environment details

  • OS: Debian GNU/Linux 8
  • Node.js version: 6.9.4
  • npm version: shipped with Node.js 6.9.4
  • @google-cloud/datastore: 0.6.1

Steps to reproduce

I ran the following example on AppEngine instance:

const Datastore = require('@google-cloud/datastore');

const datastore = Datastore({
      projectId: '<$projectId>',
      keyFilename: './gcloud-keyfile.json'
});

const query = datastore.createQuery('UserModel')
  .filter('user_name', '=', 'gosho');

datastore.runQuery(query)
  .then((results) => {
    const users = results[0];
    users.forEach((user) => console.log(user));
  });

My question is, why cannot my deployed application connect to the datastore?

Thanks!

Activity

  1. just1689 commented on Feb 2, 2017

    @just1689

    +1

  2. added
    type: bug
    api: datastore
    on Feb 2, 2017
  3. stephenplusplus commented on Feb 2, 2017

    @stephenplusplus
    Contributor

    Please try upgrading to the latest version of google-cloud or @google-cloud/datastore.

  4. goshoo commented on Feb 2, 2017

    @goshoo
    Author

    Hi stephenplusplus,

    I use the latest version of @google-cloud/datastore - 0.6.1

  5. just1689 commented on Feb 2, 2017

    @just1689

    +1 again

  6. stephenplusplus commented on Feb 2, 2017

    @stephenplusplus
    Contributor

    Sorry, I forgot to publish to npm. Please try @google-cloud/[email protected].

  7. Muesly commented on Feb 2, 2017

    @Muesly

    I'm getting the same issue, and I've tried 0.7.0 too. Any idea how to resolve this, or the last working version?

  8. stephenplusplus commented on Feb 2, 2017

    @stephenplusplus
    Contributor

    To everybody: Do you get an error? How are you authenticating?

  9. Muesly commented on Feb 3, 2017

    @Muesly

    Hi,

    Hope this helps

    var datastore = require('@google-cloud/datastore')({ projectId: <Project ID> });
    var item = datastore.key(['Key', 'Value']);
    datastore.get(item, function(err, result) 
    {
    ...

    It doesn't return with an err or result. I don't authenticate at any point. As this is server code I wasn't expecting to need to?

  10. Muesly commented on Feb 3, 2017

    @Muesly

    I'm running this through App Engine. I tried to remove the projectId as advised if running inside Google Cloud. https://www.npmjs.com/package/@google-cloud/datastore

    However, then it did call the callback with the error "Error: Sorry, we cannot connect to Google Cloud Services without a project ID. You may specify one with an environment variable named "GCLOUD_PROJECT". See https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/authentication for a detailed guide on creating an authenticated connectio..."

    I then added the GCLOUD_PROJECT variable and I have the same problem as before.

  11. stephenplusplus commented on Feb 3, 2017

    @stephenplusplus
    Contributor

    @jmdobry I'm spinning my wheels a bit trying to get an app running on GAE-- are you able to try deploying a sample Datastore app to GAE to see if you can reproduce these errors?

    Error 1: GCLOUD_PROJECT not being set by GAE
    Error 2: Hanging after an API request as described above (a runQuery or a get)

  12. jmdobry commented on Feb 3, 2017

    @jmdobry
    Contributor

    To debug I need from y'all:

    • Your app.yaml file
    • Your output of running gcloud --version

    Note when running on Google App Engine flexible environment you should instantiate the Cloud Datastore client library without passing in projectId or keyFilename (with the exception of some advanced use cases).

  13. jmdobry commented on Feb 3, 2017

    @jmdobry
    Contributor

    Also need to know if you have a yarn.lock file or not.

  14. Muesly commented on Feb 3, 2017

    @Muesly

    Output of gcloud --version:

    Google Cloud SDK 141.0.0
    app-engine-python 1.9.49
    app-engine-python-extras 1.9.49
    beta 2016.01.12
    bq 2.0.24
    bq-nix 2.0.24
    core 2017.01.20
    core-nix 2016.11.07
    gcloud
    gsutil 4.22
    gsutil-nix 4.18

  15. 7 remaining items

  16. LeoIsCoding commented on Feb 6, 2017

    @LeoIsCoding

    My node server (that exhibits the same issue) is running in the Flexible Environment (GCE based).

  17. Muesly commented on Feb 6, 2017

    @Muesly

    I've tried updating to Node 6.9.5 but it made no difference unfortunately

  18. one20 commented on Feb 6, 2017

    @one20

    I ran into this issue, was using app engine (flex+nodejs). Problem seems to be the google nodejs docker file, I created my own custom docker (https://nodejs.org/en/docs/guides/nodejs-docker-webapp/) and my app was able to connect to datastore from app engine.

    EDIT:
    I was running Node 7.4.0, google-cloud 0.46.1. Combo had the same symptoms as mentioned by others, until I decided to use a custom runtime.

  19. ofrobots commented on Feb 7, 2017

    @ofrobots
    Contributor

    We suspect that this is due to a recent change in [email protected] not dealing properly with the lack of /etc/services. We are working on an updated version of the Node.js docker image with a work-around that should be available in a few hours.

    Could folks try deploying again (in a few hours) with the latest runtime image to see if the problem gets resolved?

  20. just1689 commented on Feb 7, 2017

    @just1689
  21. LeoIsCoding commented on Feb 7, 2017

    @LeoIsCoding

    I added the "netbase" patch to my package.json as a workaround to regain access to datastore from express server. The workaround was suggested here (#1946)

  22. murgatroid99 commented on Feb 8, 2017

    @murgatroid99

    [email protected] has been published, and it should not have this failure.

  23. stephenplusplus commented on Feb 8, 2017

    @stephenplusplus
    Contributor

    Just released google-cloud version 0.46.2 -- anyone willing to test, please update and let us know how it went.

  24. just1689 commented on Feb 9, 2017

    @just1689

    It's working! It's alive!

    Thanks everyone!

  25. Muesly commented on Feb 9, 2017

    @Muesly

    I'd be happy to test, but I only import the datastore specifically so would need to wait until you released 0.7.1 of @google-cloud/datastore

  26. stephenplusplus commented on Feb 9, 2017

    @stephenplusplus
    Contributor

    The sub-modules will automatically include the fix if you un- and re-install them.

  27. Muesly commented on Feb 9, 2017

    @Muesly

    Thanks - looks to work now :)

  28. stephenplusplus commented on Feb 9, 2017

    @stephenplusplus
    Contributor

    Great, thanks for the patience and the help, everyone! If anyone is still having issues after a hard upgrade, let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: datastoretype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions