繁体   English   中英

Google Cloud Endpoints EOFException

[英]Google Cloud Endpoints EOFException

我在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

它只在调用非auth方法时有效。 怎么解决?

我使用本地服务器。

我在调用插入值时遇到了类似的问题。 我有点不同,因为我没有使用身份验证,但是我得到了同样的例外。 我正在使用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的演示应用程序。

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

如果您在本地开发服务器上运行,则在设置根URL后,在MyApi.Builder中添加以下代码段以正确设置它。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM