如何在 AppEngine 上通过来自 Node.Js 的 http 请求获取数据?
How to fetch data via http request from Node.Js on AppEngine?
当我在本地 运行 时一切正常。当我在 AppEngine 上部署我的应用程序时,出于某种原因,最简单的请求会出现超时错误。我什至实施了重试,虽然我取得了一些进展,但仍然效果不佳。
我认为这不重要,因为我在本地没有问题 运行ning,但这是我刚刚用于请求重试模块的代码:
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);
}
});
有什么建议吗?
另外,我可以在调试中看到这个错误:
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)
error 203
表示 Google App Engine 检测到 RPC 通道意外关闭并关闭实例。请求失败是由实例关闭引起的。
关于 请求导致新进程在您的应用程序中启动的另一条消息 很可能是由实例关闭引起的。当新实例开始为请求提供服务时,会出现此消息。当您的实例因 error 203
而死亡时,新的实例正在取而代之,为您的新请求提供服务并发送该消息。
为什么它在 Google Cloud Engine(或本地)上工作的解释是因为导致错误的 App Engine 组件不存在于这些环境中。
最后,如果您仍然有兴趣解决 App Engine 的问题并且 entitled to GCP support, I suggest contacting with the Technical Support team。这个问题似乎是 App Engine 独有的,但我无法进一步回答原因,这就是为什么我建议联系支持人员。他们有更多可用工具,将能够更周到地帮助调查问题。
当我在本地 运行 时一切正常。当我在 AppEngine 上部署我的应用程序时,出于某种原因,最简单的请求会出现超时错误。我什至实施了重试,虽然我取得了一些进展,但仍然效果不佳。
我认为这不重要,因为我在本地没有问题 运行ning,但这是我刚刚用于请求重试模块的代码:
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);
}
});
有什么建议吗?
另外,我可以在调试中看到这个错误:
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)
error 203
表示 Google App Engine 检测到 RPC 通道意外关闭并关闭实例。请求失败是由实例关闭引起的。
关于 请求导致新进程在您的应用程序中启动的另一条消息 很可能是由实例关闭引起的。当新实例开始为请求提供服务时,会出现此消息。当您的实例因 error 203
而死亡时,新的实例正在取而代之,为您的新请求提供服务并发送该消息。
为什么它在 Google Cloud Engine(或本地)上工作的解释是因为导致错误的 App Engine 组件不存在于这些环境中。
最后,如果您仍然有兴趣解决 App Engine 的问题并且 entitled to GCP support, I suggest contacting with the Technical Support team。这个问题似乎是 App Engine 独有的,但我无法进一步回答原因,这就是为什么我建议联系支持人员。他们有更多可用工具,将能够更周到地帮助调查问题。