通过 REST 调用 CloudML Predict 时遇到内部错误
Internal Error encountered while invoking CloudML Predict via REST
我在 GAE 中有我的应用程序 运行。此应用程序对我的 CloudML 进行 REST 调用。
这是代码
GoogleCredential credential = GoogleCredential.getApplicationDefault()
.createScoped(Collections.singleton(CLOUDML_SCOPE));
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
HttpRequestInitializer requestInitializer = request -> {
credential.initialize(request);
request.setReadTimeout(0);
};
HttpRequestFactory requestFactory = httpTransport.createRequestFactory(
requestInitializer);
GenericUrl url = new GenericUrl(predictRestUrl);
JacksonFactory jacksonFactory = new JacksonFactory();
JsonHttpContent jsonHttpContent = new JsonHttpContent(jacksonFactory, getPayLoad());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
jsonHttpContent.setWrapperKey("instances");
jsonHttpContent.writeTo(baos);
LOG.info("Executing request... " + baos.toString());
HttpRequest request = requestFactory.buildPostRequest(url, jsonHttpContent);
HttpResponse response = request.execute();
我已将 ReadTimeOut 设置为 0,因为我经常遇到读取超时异常。
现在使用此代码,我经常从 CloudML 收到以下错误响应
com.google.api.client.http.HttpResponseException: 500 Internal Server Error
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"errors": [
{
"message": "Internal error encountered.",
"domain": "global",
"reason": "backendError"
}
],
"status": "INTERNAL"
}
}
我们从哪里可以获得对 CloudML 的 REST 调用的日志?如何进一步调试?
我们与@sag 合作,确定 500 错误是由于长时间 "cold start" 导致超时的结果。如果您有一段时间没有向您的模型发送流量,或者如果您发送的流量足够我们需要启动更多实例,您将点击 "cold start",其中启动了一个或多个实例。目前,这可能是一个漫长的过程,有时我们会超时并可能导致 500 错误。
可以安全地重试这些错误;我们建议使用指数退避。
我在 GAE 中有我的应用程序 运行。此应用程序对我的 CloudML 进行 REST 调用。
这是代码
GoogleCredential credential = GoogleCredential.getApplicationDefault()
.createScoped(Collections.singleton(CLOUDML_SCOPE));
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
HttpRequestInitializer requestInitializer = request -> {
credential.initialize(request);
request.setReadTimeout(0);
};
HttpRequestFactory requestFactory = httpTransport.createRequestFactory(
requestInitializer);
GenericUrl url = new GenericUrl(predictRestUrl);
JacksonFactory jacksonFactory = new JacksonFactory();
JsonHttpContent jsonHttpContent = new JsonHttpContent(jacksonFactory, getPayLoad());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
jsonHttpContent.setWrapperKey("instances");
jsonHttpContent.writeTo(baos);
LOG.info("Executing request... " + baos.toString());
HttpRequest request = requestFactory.buildPostRequest(url, jsonHttpContent);
HttpResponse response = request.execute();
我已将 ReadTimeOut 设置为 0,因为我经常遇到读取超时异常。
现在使用此代码,我经常从 CloudML 收到以下错误响应
com.google.api.client.http.HttpResponseException: 500 Internal Server Error
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"errors": [
{
"message": "Internal error encountered.",
"domain": "global",
"reason": "backendError"
}
],
"status": "INTERNAL"
}
}
我们从哪里可以获得对 CloudML 的 REST 调用的日志?如何进一步调试?
我们与@sag 合作,确定 500 错误是由于长时间 "cold start" 导致超时的结果。如果您有一段时间没有向您的模型发送流量,或者如果您发送的流量足够我们需要启动更多实例,您将点击 "cold start",其中启动了一个或多个实例。目前,这可能是一个漫长的过程,有时我们会超时并可能导致 500 错误。
可以安全地重试这些错误;我们建议使用指数退避。