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

≡放荡痞女 提交于 2019-12-11 19:52:47

问题


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:


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.



来源:https://stackoverflow.com/questions/51699804/how-to-fetch-data-via-http-request-from-node-js-on-appengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!