Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Natural Language API hangs forever - does not resolve #273

Closed
joseocasioserra opened this issue Jul 24, 2019 · 7 comments
Closed

Natural Language API hangs forever - does not resolve #273

joseocasioserra opened this issue Jul 24, 2019 · 7 comments
Labels
api: language Issues related to the googleapis/nodejs-language API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.

Comments

@joseocasioserra
Copy link

joseocasioserra commented Jul 24, 2019

The following issue only happens on a server, locally works fine.

When using the Natural Language API, the call that produces the sentiment analysis of a text ( analyzeSentiment() ) hangs indefinitely; however, other APIs such as Cloud Storage work fine.

This is a similar issue that I found: googleapis/google-cloud-node#1955 which was resolved by an updated version of the library.

I isolated the issue by only running the following piece of code, taken straight from the documentation.

Both environments (local, ec2) have the same setup: google creds, npm version, node version, languageAPI version

// Imports the Google Cloud client library
const language = require('@google-cloud/language');

// Instantiates a client
const client = new language.LanguageServiceClient();

// The text to analyze
const text = 'Hello, world!';

const document = {
  content: text,
  type: 'PLAIN_TEXT',
};

// Detects the sentiment of the text
client
  .analyzeSentiment({document: document})
  .then(results => {
    const sentiment = results[0].documentSentiment;

    console.log('success ', sentiment);
  })
  .catch(err => {
    console.error('ERROR:', err);
  });

Environment details

  • OS: Local - MacOS 10.14.5 / EC2 - CentOS Linux release 7.6.1810
  • Node.js version: 10.16.0
  • npm version: 6.9.0
  • @google-cloud/language version: 3.2.4

Steps to reproduce

  1. Run sample code above
  2. client.analyzeSentiment({document: document}) never resolves

Thanks!

@bcoe bcoe added type: question Request for information or clarification. Not an issue. needs more info This issue needs more information from the customer to proceed. and removed needs more info This issue needs more information from the customer to proceed. labels Jul 29, 2019
@bcoe
Copy link
Contributor

bcoe commented Jul 29, 2019

@joseocasioserra this almost sounds like a firewall issue, can you confirm that you're able to curl language.googleapis.com when SSHd into the EC2 instance?

@bcoe bcoe added the needs more info This issue needs more information from the customer to proceed. label Jul 29, 2019
@joseocasioserra
Copy link
Author

joseocasioserra commented Jul 30, 2019

@bcoe thanks for the prompt reply.
I tried the curl provided and this is my output on the EC2 instance:

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/</code> was not found on this server.  <ins>That’s all we know.</ins>

@bcoe
Copy link
Contributor

bcoe commented Jul 30, 2019

@joseocasioserra looks like you can reach the external server, is there an ERROR: in the logs of the EC2 instance when the program times out?

@joseocasioserra
Copy link
Author

joseocasioserra commented Jul 30, 2019

@bcoe other APIs work fine, like Cloud Storage which I already tested

I have tried everything I can think of - new ec2 instances, isolated scripts and all the @google-cloud/language versions.

UPDATE: Forgot to mention: The reason why I am leaning towards an issue in the library is because I also replicated the code on python and it works perfectly on python; however, in my specific use case I need to use node.

I am currently doing setInterval each second to print out the promise and it never resolves and after a while it errors out due to timeout.

This is the output of that function.

Promise { <pending> }
Promise { <pending> }
Promise { <pending> }
Promise { <pending> }
Promise { <pending> }
(node:25959) UnhandledPromiseRejectionWarning: Error: Retry total timeout exceeded before any response was received
    at repeat (/myapps/node_modules/google-gax/build/src/normalCalls/retries.js:80:31)
    at Timeout.setTimeout [as _onTimeout] (/myapps/node_modules/google-gax/build/src/normalCalls/retries.js:112:25)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:25959) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:25959) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Promise {
  <rejected> { Error: Retry total timeout exceeded before any response was received
      at repeat (/myapps/node_modules/google-gax/build/src/normalCalls/retries.js:80:31)
      at Timeout.setTimeout [as _onTimeout] (/myapps/node_modules/google-gax/build/src/normalCalls/retries.js:112:25)
      at ontimeout (timers.js:436:11)
      at tryOnTimeout (timers.js:300:5)
      at listOnTimeout (timers.js:263:5)
      at Timer.processTimers (timers.js:223:10) code: 4 } }

Any ideas or fixes are more than welcome.

@joseocasioserra
Copy link
Author

@bcoe Hello,

Just wondering if you saw my previous response, I am still blocked by this issue. Thanks!

@google-cloud-label-sync google-cloud-label-sync bot added the api: language Issues related to the googleapis/nodejs-language API. label Jan 30, 2020
@SHwan93
Copy link

SHwan93 commented Jul 1, 2020

Is there any solution?
Currently I am having this problem

@telpirion
Copy link
Contributor

Thank you for filing this issue. It looks like we asked you for more information from your logs but didn't receive that information. We are unable to proceed with this issue until then, so we are closing it. Please feel free to re-open this issue with more information.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: language Issues related to the googleapis/nodejs-language API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants