【问题标题】:Google Cloud Endpoints EOFException谷歌云端点 EOFException
【发布时间】:2013-12-20 02:07:59
【问题描述】:

我在 AppEngine 中有以下方法:

@ApiMethod(name = "authed", path = "greeting/authed")
public HelloGreeting authedGreeting(User user) {
    ...
}

我在 Android AsyncTask 中的 doInBackground 方法:

HelloGreeting hg = null;
try {
    hg = service.authed().execute();
} catch (IOException e) {
    Log.d("error", e.getMessage(), e);
}
return hg;

我遇到了ff错误:

/_ah/api/.../v1/greeting/authed: java.io.EOFException

在logcat中:

Problem accessing /_ah/api/.../v1/greeting/authed. Reason: INTERNAL_SERVER_ERROR
    at java.util.zip.GZIPInputStream.readUByte
    at java.util.zip.GZIPInputStream.readUShort
    at java.util.zip.GZIPInputStream.readUShort

仅在调用非认证方法时有效。如何解决?

我正在使用本地服务器。

【问题讨论】:

  • 这是针对本地服务器的吗?

标签: java android google-app-engine gzip google-cloud-endpoints


【解决方案1】:

我在调用插入值时遇到了类似的问题。我的略有不同,因为我没有使用身份验证,但是我得到了同样的异常。我正在使用 appengine-java-sdk-1.8.8。我能够进行有此错误的其他端点调用。我查看了生成的代码,我看到的工作调用与非工作调用的区别在于 HttpMethod。失败的调用被定义为"POST"。我可以使用 @ApiMethod 注释中的注释属性 httpMethod=ApiMethod.HttpMethod.GET 来更改它。

@ApiMethod(httpMethod = ApiMethod.HttpMethod.GET, name = "insertUserArtist", path = "insertUserArtist")

然后我重新生成了客户端代码,我能够在没有收到可怕的EOFException 的情况下拨打电话。我不确定为什么 POST 不能正常工作,但将其更改为 GET 工作。这可能会提出一些关于可以发送多少数据以及应该解决的问题(可能是图书馆问题)。我将研究创建一个演示应用程序以提交给 Google。

【讨论】:

    【解决方案2】:

    如果您传递了一个“实体”对象,那么 POST 将起作用。如果您传递原始数据类型,您将无法使用 HttpMethod.GET。

    【讨论】:

      【解决方案3】:

      如果您在本地开发服务器上运行, 然后在MyApi.Builder中添加如下sn-p,设置root url后正确设置。

          .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
                      @Override
                      public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
                          abstractGoogleClientRequest.setDisableGZipContent(true);
                      }
                  })
      

      来源:https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints

      【讨论】:

        猜你喜欢
        • 2015-10-27
        • 2014-07-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-06
        • 1970-01-01
        相关资源
        最近更新 更多