0

Everything works perfect when I run locally. When I deploy my app on AppEngine, for some reason, the most simple request gets timeout errors. I even implemented retry and, while I made some progress, it still not working well.

I don't think it matter since I don't have the problem running on local, but here's the code I just used for request-retry module:

request({
        url: url,
        maxAttempts: 5,
        retryDelay: 1000, // 1s delay 

    }, function (error, res, body) {
        if (!error && res.statusCode === 200) {
            resolve(body);
        } else {
            console.log(c.red, 'Error getting data from url:', url, c.Reset);
            reject(error);
        }
    });

Any suggestions?

Also, I can see this errors in the Debug:

This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

────────────────────

The process handling this request unexpectedly died. This is likely to cause a new process to be used for the next request to your application. (Error code 203)

Community
  • 1
  • 1
SharpBCD
  • 547
  • 1
  • 7
  • 25
  • Hi! I would need more information to know what's different between your local environment and the AppEngine one. What kind of Google AppEngine are you using (standard or flex)? Where is your local and where your AppEngine deployment geographically (US, Europe, etc)? Also, where is the data you are trying to fetch? I it a 3rd party? Knowing what you are requesting will help when trying to reproduce the issue – Guillermo Cacheda Aug 06 '18 at 09:37
  • Standard, located Europe west1. I can give you the end-points I'm fetching as well but I rather in a pm. I just don't know how to send PM on stackoverflow, maybe I don't have the rights yet. – SharpBCD Aug 06 '18 at 10:25
  • When doing HTTP requests in AppEngine standard you need to use [url.fetch](https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.api.urlfetch#google.appengine.api.urlfetch.fetch). If you are not using it already, [here is the documentation](https://cloud.google.com/appengine/docs/standard/python/issue-requests) about it. Regarding the end-points, if you consider it to be sensitive information, is better to not share them at all. – Guillermo Cacheda Aug 06 '18 at 10:32
  • Thanks for the links but they are for Python, not Node. I also read this [page](https://cloud.google.com/appengine/docs/standard/python/issue-requests) but the node.js is disabled. Information is not sensitive but, since there is a 3rd party, I thought not to make them public. – SharpBCD Aug 06 '18 at 10:49
  • Sorry about that! Didn't realize you were using NodeJS. I've made my own application to do requests and can't reproduce the issue. I'm using the `"request": "^2.81.0"` dependency and requesting from this url `http://jsonplaceholder.typicode.com/posts/1`. Could you try with this url too? Are you using a different dependency? Also, you commented about progress after implementing the retries, did the success rate of the request improve after it? How much? And last question, do you know how much time passes between the request starts and until it fails due to timeout? – Guillermo Cacheda Aug 07 '18 at 10:02
  • I used "request" and now "requestretry" which has "request" as dependency. I implemented "retry" after I noticed the error was almost random. about 1 in 3 request were throwing the error. After request-retry, only from time to time I got the error. Also, I can see this errors in Debug: _"This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application."_ (continuing...) – SharpBCD Aug 07 '18 at 16:40
  • ... and _"The process handling this request unexpectedly died. This is likely to cause a new process to be used for the next request to your application. (Error code 203)"_ Since it created so many problems I moved to GCE and, with the minimal configuration, I have absolutely no problem. It has to be an AppEngine issue. I'll be happy to add you in the project as editor if you can send me your google id. – SharpBCD Aug 07 '18 at 16:40
  • I've posted an answer with more details about those messages and why it's working on GCE and not in GAE. – Guillermo Cacheda Aug 09 '18 at 14:25

1 Answers1

0

The error 203 means that Google App Engine detected that the RPC channel has closed unexpectedly and shuts down the instance. The request failure is caused by the instance shutting down.

The other message about a request causing a new process to start in you application is most likely caused by the instances shutting down. This message appears when a new instance starts serving a request. As your instances were dying due to the error 203, new instances were taking its place, serving your new requests and sending that message.

An explaination for why it's working on Google Cloud Engine (or locally) is because the App Engine component causing the error is not present on those environments.

Lastly, if you are still interested in solving the issue with App Engine and are entitled to GCP support, I suggest contacting with the Technical Support team. The issue seems exclusive to App Engine, but I can't answer further about the reason why, that's why I'm suggesting contacting with support. They have more tools available and will be able to help investigate the issue more thoughtfully.

Guillermo Cacheda
  • 2,162
  • 14
  • 23
  • Indeed @Guillermo, this is the explanation for the system errors. However they were caused by the bug associated with the url fetching. This is also confirmed by not having the same issue at all on GCE. So should we conclude that this is a bug in AppEngine? After all, the Node.js is in beta. – SharpBCD Aug 09 '18 at 15:42
  • It's true that the issue seems exclusive to App Engine, but I can't answer further about the reason why. That's why I suggested contacting with support about it. They have more tools available that can investigate the issue more thoughtfully. – Guillermo Cacheda Aug 09 '18 at 15:59
  • got it. Could you update your answer with this info as well so I can close the question? – SharpBCD Aug 09 '18 at 16:35
  • @SharpBCD I've rephrased the answer to add the comment's info. – Guillermo Cacheda Aug 10 '18 at 06:54