How to fetch data via http request from Node.Js on AppEngine?

996 Views Asked by At

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)

1

There are 1 best solutions below

4
On BEST ANSWER

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.