[英]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.